Skip to content
mattidupre edited this page Sep 23, 2014 · 2 revisions

Frequently Asked Questions

Why does shimming files from the ./node_modules directory leave out some dependencies?

The fix

Always call browserify-shim from package.json via Browserify's "transform" attribute.

"browserify": "transform": ["browserify-shim"]

Why?

When calling browserify-shim via Browserify's API, shim will only transform files within the scope of the parent package.json file. As per the Browserify docs for b.transform():

If opts.global is true, the transform will operate on ALL files, despite whether they exist up a level in a node_modules/ directory.

However, as of 1.7.0, adding browserify-shim via b.transform({global: true}, shim); or b.transform({global: true}, 'browserify-shim'); will cause unpredictable results. The sanctioned method above using package.json will still allow inline Browserify API calls to include the browserify-shim transform. There is no need to use b.transform();