moduleify is a browserify transform for shimming globals-polluting libraries.
npm install moduleifygit clone https://github.com/pluma/moduleify.git
cd moduleify
npm install
make testangular = {awesome: true};
// No CommonJS export, just a globalvar ng = require('./vendor/angular');
console.log(ng); // {awesome: true}var browserify = require('browserify'),
moduleify = require('moduleify'),
b = browserify();
b.transform(moduleify({
"vendor/angular.js": "angular"
}));
b.bundle().pipe(require('fs').createWriteStream('bundle.js'));Creates a browserify transform that will append module.exports statements
to all matching files.
If rules is an object, each filename will be checked against its keys.
If one of the keys is contained in the filename, the global with the name
matching the value the key is mapped to will be exported.
moduleify({
"vendor/angular.js": "angular",
"jquery": "$"
});
Alternatively rules can be an array containing tuples of paths and names.
Each filename will be checked against each path. The path can either be
a string to be found in the filename or a regular expression to test against.
In either case path separators in the filename will be converted to slashes before testing for matches.
moduleify([
["vendor/angular", "angular"],
[/vendor\/jquery(-\d+(\.\d+)+)?\.js$/, "$"]
]);The MIT/Expat license.


