Package Exports
- browserify-shim
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (browserify-shim) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
browserify-shim 
Shims modules that aren't installed as npm
modules so they can be browserified even if they aren't commonJS
compatible.
var browserify = require('browserify')
, shim = require('browserify-shim');
var bundled = browserify({ debug: true })
// jquery attaches itself to the window as '$' so we assign the export accordingly
.use(shim({ alias: 'jquery', path: './js/vendor/jquery.js', export: '$' }))
// underscore is commonJS compliant, so no further export is needed which we specify by assigning it 'null'
.use(shim({ alias: 'underscore', path: './js/vendor/underscore.js', export: null }))
// it is important to use shim.addEntry instead of addEntry supplied by browserify
.use(shim.addEntry('./js/entry.js'))
.bundle();
fs.writeFileSync(builtFile, bundled);
Install
npm install browserify-shim
Features
- allows non commonJS modules to be shimmed in order to be browserified by specifying an alias, the path to the file and the identifier under which the module attaches itself to the global window object
- allows commonJS modules that are not residing in your
node_modules
to be loaded from a specific path
Limitations
- in order for browserify-shim to work correctly, you must not use browserify's built in
addEntry(..)
, butuse(shim.addEntry(..))
instead (see example)