deglobalify
deglobalify copied to clipboard
Allow export mappings outside of `require` calls
It would be neat if we could declare the export mappings outside the require
calls, e.g.
//file: /public/scripts/app.js
var domready = require('domready') // regular npm module
, badmodule = require('./vendor/badmodule.js'); // returns an exports object
domready(function () {
console.log(badmodule.myfunc()); // prints 42
});
//file: package.json
deglobalify:{
'./vendor/badmodule.js': ['myfunc']
}
The advantage would be that your require
s stay clean and if badmodule
gets updated to be commonjs-compatible you don't have to change any of your require calls, only the deglobalify
config inside package.json
This would also allow use of this module with es6...