Repository navigation
Resolve builtins with --no-browser-field, fixes #1654 - #1826
goto-bus-stop wants to merge 4 commits into
Conversation
ab1e4b1 to
a9f2ab1
Compare
a9f2ab1 to
0047b78
Compare
|
Thanks @goto-bus-stop for the fix. I can confirm that it works and fixes an issue I have. Is it planned to release this fix ? |
|
Thanks @goto-bus-stop for checking again. Is it ready to merge ? |
|
We are having this problem too. |
| ? function (id, opts, cb) { | ||
| if (!opts.basedir) opts.basedir = path.dirname(opts.filename) | ||
| // Resolve builtin modules. | ||
| if (self._mdeps.options.modules[id]) return process.nextTick(function () { |
There was a problem hiding this comment.
this should use resolve’s isCore functionality, i think?
There was a problem hiding this comment.
@ljharb I don't believe so, as custom built-ins can be fed into Browserify, and those won't be picked up by resolve.isCore. See: https://github.com/browserify/browserify/blob/master/index.js#L551-L553
There was a problem hiding this comment.
If those can override the default ones, then that's a fair point - but then browserify should be using resolve's node-version-specific logic for the defaults, which it doesn't appear to be.
There was a problem hiding this comment.
@ljharb Yes, it overrides the defaults, in a way. It's just a direct replacement of built-in resolution. Browserify doesn't use the node-version-specific logic, and that's a separate issue from this one that's worth logging. I'm maintaining a fork right now with this change, and I'd like to be able to depend on the officially published version. Is there anything else holding this up or can it move forward?
|
Let me know if there's anything I can do to help push a fix for this over the finish line. Use case: I'm using Browserify to custom-tailor third-party modules for use within the Postman Sandbox execution environment (see: https://explore.postman.com/templates/7170/browserify-cdn-modules). Being an Electron app that hosts an even more restricted execution environment, a Browserify CLI call needs to look something like this: Because of this bug, I get the following error: This PR fixes the issue for me. Thanks! |
Currently when
browserField: falseor--no-browser-fieldis used, builtin modules likepathandstreamare not resolved correctly. They go through theresolvemodule, which simply returns the module name for core modules. Then module-deps tries to read the file namedpathwhich doesn't exist (usually).With this patch, builtin modules are checked before calling into the
resolvemodule.TODO:
opts.builtins(currently it will crash like in Unable to resolve stream module with browserField false #1654)