-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
8.1.1 fails to resolve modules from "browser" field #1072
Comments
Hmm I'm a bit of a doofus and my example is broken for other reasons - will link an updated one in a moment. |
Alright, issue is present in this example repo. Doesn't occur when being required within the bundle (as browser-resolve is used then), but occurs when requiring directly (
|
According to the documentation for That's not even really what the If you could use the API instead of the CLI, then at least for the time being (until you see how this shakes out) you could do this, right?: b.require(require('browserify/package.json').browser.some-lib) |
It may not be exactly what the browser it's meant for, no. In the actual case, the errors being run into here were for shimming angular modules. Then the list was then passed as external to the main bundle, and passed as requires to our vendor bundle. Given the need for the proper names to be exposed here, the fix (without browserify changes) would actually be to, similar to what you said, require the filename directly and specify the name to expose This did however, work before - only broken by the use of the node resolve, which would likely return to normal by changing |
I think the fix here is to first try to bresolve() the file and only if bresolve() fails then resolve() the file. |
But intentionally or accidentally? That usage doesn't seem to be documented and apparently there wasn't test coverage for it either.
I've proposed (#1077) eliminating that pathname resolution that was added recently, reverting to doing it in module-deps.
Isn't bresolve a superset of resolve? |
I'm having a problem with this too, whether or not it was an intentional behaviour. My use case is for building separate bundles for library and application code. It was working by setting up named entries in the |
I've not checked, but I expected the changes in 8.1.2 would've fixed this. Does it not @baseten? |
@omsmith it doesn't appear to. I'm still getting the same error in |
Yeah, I am also getting this issue now with 8.1.3. Was on 5.x as hadn't upgraded for a while, and now that I'm on the latest version it is broken as per @omsmith & @baseten's experiences. I too was creating a separate vendor / library module bundle by passing the aliases defined in package.json into the .require() function during my gulp bundle task. Am doing this instead of just doing a .require() on the relative path for the vendor libs as I need browserify-shim to kick in for the Global namespacing adjustments.
Then...
now gives the Cannot find module error. I am happy to try a few workarounds, like the one suggested:
...however does anyone know if browserify-shim will kick-in from package.json and set the Global namespace objects accordingly or if package.json is ignored entirely when doing a direct .require() on the file path ?? |
@justinware I can confirm that doing b.require('./node_modules/angular/angular.js', {expose: 'angular'}); does indeed work. However, I too am trying to figure out what, if anything, browserify-shim will do from package.json. I'm seeing very odd behavior. For some of my shims (kendo UI, which depends: jQuery), I'm seeing jQuery pulled in by browserify-shim without explicitly calling b.require('jquery'). However, for other shims (like angular which depends: jQuery), jQuery is Not pulled in. Very confusing and odd. |
The changes upstream in resolve@1.1.4 and module-deps appear to have fixed this issue.
|
Very cool - thanks @substack |
Minimal reproduction: https://gist.github.com/omsmith/a6b8876a4354960a65f4Minimal reproduction: https://github.com/omsmith/browserify-8.1.1-resolve-issue
Works fine in 8.1.0, but as of 8.1.1
browser
entries don't appear to be picked upThe text was updated successfully, but these errors were encountered: