-
-
Notifications
You must be signed in to change notification settings - Fork 87
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
Unable to find a browserify-shim config section in the package.json #61
Comments
I guess this is actually a duplicate of #44, but the repro case is super simple here. Unzip http://cl.ly/2d0a1f1p3P0n, It's not feasible or realistic to insist that every file required by an application using b-shim will have a package.json with shims configured. |
Could you please put whatever is in that zip file into a public github repo? Thanks. |
Thanks, will have a look. |
|
Any ideas how to fix this? I'd love to use browserify-shim but this is a showerstopper for me. |
I had a look and believe the reason for this failing is that |
This worked for me, thanks. |
browserify supports having files outside of a 'app root', so I think browserify-shim should too! Seems like a valid bug to me additionally, a lot of people these days are dividing big apps into multiple modules each with a separate |
+1 for enabling Besides, if browserify works when not in the app root (according to @timruffles), then the shim should also. |
browserify-shim traverses upwards from each file looking for the "mothership" There's no reasonable way around this. If you have files above the package, there's no way for browserify-shim to figure out how to handle them. They get transformed but b-shim has no way to decide how to operate on them. This doesn't preclude you from splitting up modules into smaller modules though. There just has to be a package.json at or above every required file with |
It doesn't need to do anything to the files I'm requiring, it should just On Wed, Apr 1, 2015 at 12:46 PM, Ben Drucker [email protected]
|
That's not an assumption that can be made though. The only way to allow arbitrary files to be required is if b-shim failed silently if no shim configuration could be located. |
Yup - sounds like a good behaviour to me. Why modify more behaviour than On Wed, Apr 1, 2015 at 2:48 PM, Ben Drucker [email protected]
|
I didn't mean to imply that silent failure is on the table. Someone without knowledge of Browserify internals could reasonably expect that requiring a file above the package would work with browserify-shim. The only thing we can consider for the small number of users affected by this would be to support a transform option that would ignore the specific case of mothership succeeding but not finding anything. Even that I'm not sure about. It's a lot of maintenance cost for a use case that still doesn't make sense to me. |
I'll toss in another use case for this behavior: incrementally moving a large legacy codebase to use browserify. Here's a brief overview of what we're trying to do at my company. Naturally our JS code is composed of our own code and a number of third-party libraries. We store those libraries in a separate repository and move them into place at build time. We are trying to start introducing browserify into our code base, for both modularizing our own code and simplifying dependency management for third-party libs. This requires being able to specify the different paths for the libs we're loading, which we can do in browserify via setting search paths, but not (AFAICT) in browserify-shim. Our current workaround is to put a package.json file with a Our first attempt had the package.json in our js folder point to a shims configuration file that included relative paths into our third-party js folder, and we had expected that this would work, since we had defined a shims section with relative path to each dependency, but browserify-shim choked until we moved that browserify-shim section to a package.json in the common root dir. That's why we feel this is an unnecessary requirement; we'd told browserify-shim how to shim the dependency via relative paths, but it required us to have the package.json file in a particular location instead, even though it had the same contents (though obviously the path changed). If this really is a dead-end, I would really appreciate your advice as to how best to handle this case. Thanks! |
Happy to clarify that it is. b-shim needs to read config from your package. All it gets for each file is the file path and the file contents. So by definition it can't handle files above the package. I know that's potentially frustrating but there's no choice here. |
Workaround (mostly for my own reference)
The common_components directory is symlinked from within the app directories. I also got this error on code within the common_components directory, none of which have a
This {
"browserify-shim": {}
} Not an elegant solution, but this kills the error. |
I'd like to add another case where this is a problem: I'm working on a branch of a module I'm using in my project, so I've used
|
Adding my case too : Could this be an issue in mothership (https://github.com/thlorenz/mothership), which is used to locate the package.json ? Copying our package.json near the "real" node_modules folder fixes the issue, but feels dirty. |
I'm also having this issue with the case that @Fauntleroy describes — where I'm |
@pieterjandesmedt That workaround helped wonders — Thank you! |
Ditto having problems using ./my-module-1/: Any call to browserify in my-module-2 will generate this error. I suppose we could "work around" it by deleting the link and copying into node_modules what was previously linked to, but that is sad 😿 |
I'm getting this when trying to require a file outside my app's directory. So just the presence of
require('../hmm')
will spit outThe text was updated successfully, but these errors were encountered: