deglobalify icon indicating copy to clipboard operation
deglobalify copied to clipboard

Allow export mappings outside of `require` calls

Open creynders opened this issue 10 years ago • 1 comments

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 requires 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

creynders avatar Dec 09 '14 08:12 creynders

This would also allow use of this module with es6...

arcticShadow avatar Nov 03 '15 00:11 arcticShadow