Node: Make "exports" a const

Created on 7 Mar 2017  路  4Comments  路  Source: nodejs/node

Maybe something like (totally not sure if this is doable or if it's even a good idea):

NativeModule.wrapper = [
  '(function (require, module, __filename, __dirname) { const exports = module.exports; ',
  '\n});'
];

The reasoning for this is to give users a warning if they try to change the exports variable reference.

feature request module

Most helpful comment

Not a good idea, exports = module.exports = function MyClass() {}; is common, why would we want to break that?

All 4 comments

-1 I don't think any benefit provided by this outweighs the breakage this would cause.

Not a good idea, exports = module.exports = function MyClass() {}; is common, why would we want to break that?

Please don't. Many of npm packages will be doomed after this obscure change. 馃拃

I'll close, too disruptive.

Was this page helpful?
0 / 5 - 0 ratings