According to the browserify-shim docs, you can specify which globals browserify-shim should be exposed from your deprecated modules using the following syntax in package.json :
{ "browserify-shim": { "legacyModule": "myVar" } }
I want the obsolete module to be accessible via require('legacyModule') and window.myVar .
From my experience, if the non-commonjs module I'm trying to use uses window.myVar = x or just myVar = x , the module is displayed globally and is accessible via require() , as expected.
However , when an obsolete module uses var myVar = x , this is why the problem is that the module is only accessible through require('legacyModule') and not through window.myVar .
The browser-firmware documentation states that:
In addition, it handles the following real-world cases:
- Modules that simply declare
var foo = ... at the script level and assume that it is attached to the window object. Because the only way they will ever be executed is through the global context - "um ... NO ?!"
source share