Closed albertosantini closed 6 years ago
@albertosantini: The alias should actually be --alias /bar.js:/foo.js
, but judging by your comments in nzakas/eslint#119, that will not be sufficient.
@Nami-Doc: You're on Windows, right? Mind looking into this?
Sure !
I repeated the test using --alias /bar.js:/foo.js
and I confirm the results are the same.
Yes, I can confirm the bug. I'll look into it.
When I dump CORE_MODULES
then corePath
before throwing, I get this
{ buffer: '%%AppData%\\npm\\node_modules\\commonjs-everywhere\\node_modules\\buffer-browserify\\index.js',
constants: '%%AppData%\\npm\\node_modules\\commonjs-everywhere\\node_modules\\constants-browserify\\constants.json',
crypto: '%%AppData%\\npm\\node_modules\\commonjs-everywhere\\node_modules\\crypto-browserify\\index.js',
events: '%%AppData%\\npm\\node_modules\\commonjs-everywhere\\node_modules\\events-browserify\\events.js',
http: '%%AppData%\\npm\\node_modules\\commonjs-everywhere\\node_modules\\http-browserify\\index.js',
punycode: '%%AppData%\\npm\\node_modules\\commonjs-everywhere\\node_modules\\punycode\\punycode.js',
querystring: '%%AppData%\\npm\\node_modules\\commonjs-everywhere\\node_modules\\querystring\\index.js',
vm: '%%AppData%\\npm\\node_modules\\commonjs-everywhere\\node_modules\\vm-browserify\\index.js',
zlib: '%%AppData%\\npm\\node_modules\\commonjs-everywhere\\node_modules\\zlib-browserify\\index.js',
_stream_duplex: '%%AppData%\\npm\\node_modules\\commonjs-everywhere\\node\\lib\\_stream_duplex.js',
_stream_passthrough: '%%AppData%\\npm\\node_modules\\commonjs-everywhere\\node\\lib\\_stream_passthrough.js',
_stream_readable: '%%AppData%\\npm\\node_modules\\commonjs-everywhere\\node\\lib\\_stream_readable.js',
_stream_transform: '%%AppData%\\npm\\node_modules\\commonjs-everywhere\\node\\lib\\_stream_transform.js',
_stream_writable: '%%AppData%\\npm\\node_modules\\commonjs-everywhere\\node\\lib\\_stream_writable.js',
assert: '%%AppData%\\npm\\node_modules\\commonjs-everywhere\\node\\lib\\assert.js',
console: '%%AppData%\\npm\\node_modules\\commonjs-everywhere\\node\\lib\\console.js',
domain: '%%AppData%\\npm\\node_modules\\commonjs-everywhere\\node\\lib\\domain.js',
freelist: '%%AppData%\\npm\\node_modules\\commonjs-everywhere\\node\\lib\\freelist.js',
path: '%%AppData%\\npm\\node_modules\\commonjs-everywhere\\node\\lib\\path.js',
readline: '%%AppData%\\npm\\node_modules\\commonjs-everywhere\\node\\lib\\readline.js',
stream: '%%AppData%\\npm\\node_modules\\commonjs-everywhere\\node\\lib\\stream.js',
string_decoder: '%%AppData%\\npm\\node_modules\\commonjs-everywhere\\node\\lib\\string_decoder.js',
sys: '%%AppData%\\npm\\node_modules\\commonjs-everywhere\\node\\lib\\sys.js',
url: '%%AppData%\\npm\\node_modules\\commonjs-everywhere\\node\\lib\\url.js',
util: '%%AppData%\\npm\\node_modules\\commonjs-everywhere\\node\\lib\\util.js' } undefined
Actually, whatever are the params I pass it, I always get the same exception (which seems expected since core-modules doesn't export fs).
Any progress on this? I just ran into this issue. Any pointers on where to look to investigate where this is falling down?
In my case, I'm not trying to alias a Node.JS core module but a CommonJS package name (and providing a path to a shim that grabs the global var).
cjsify --verbose --no-node -w -s test/all-tests-built.map -a lazy.js:/shims/lazy.js test/all-tests.js -o test/all-tests-built.js
Output:
required "lazy.js" from "/js/<file>"
ERROR: Cannot find module "lazy.js" in "<project root>"
I tried:
-a lazy.js:/shims/lazy.js
-a lazy.js:shims/lazy.js
--amend lazy.js:shims/lazy.js
Sorry, I just don't have the ability to test on a Windows machine, and frankly this issue is not enough of an incentive to go out and acquire a Windows license. I'd happily review a PR though if someone wants to take it on.
Understandable. I had switched to this from watchify as it had stopped working recently. I was able to spot the breakage on that project and get a fix accepted, so I've moved back.
Thanks for the ride, but the time is over. :)
cjsify --verbose --alias bar.js:foo.js main.js > p.js
bar.js
foo.js
main.js
The alias is not used.
Furthermore, if you remove the offending line (the required fs module) and execute
node p.js
is printed42
and not3.14
. Another confirm the alias is not used.This is issue is related to https://github.com/nzakas/eslint/issues/119.