thlorenz / browserify-shim

📩 Makes CommonJS incompatible files browserifyable.
MIT License
934 stars 87 forks source link

Only works if package.json in same directory as JS? #218

Closed krisdigital closed 7 years ago

krisdigital commented 7 years ago

I have a package.json which is outside of the JS folder for some reasons and browserify does not shim anything.. If I put a second package.json into the JS folder only with the shim options it starts working..

Is that a feature or a bug?

Is it documented somewhere?

bendrucker commented 7 years ago

As of 2c8769800b1b0e349854022011162624443ab5b6 it's well documented why this is an immovable restriction:

browserify-shim walks upwards from each source file and uses the first "browserify-shim" configuration it finds in a package.json file. You can't shim files outside your project from your project's package you. You can add multiple package.json files as long as browserify-shim can always find a package above each source file with the right configuration.