0

In node module.js file there is this line of code:

exports = module.exports = {
   makeRequireFunction,
   stripBOM,
   addBuiltinLibsToObject
};

What is this doing?

 exports = module.exports 

Ultimately, exports is being set to this new object:

= {
   makeRequireFunction,
   stripBOM,
   addBuiltinLibsToObject
};

Why is exports = module.exports needed?

lance-p
  • 1,050
  • 1
  • 14
  • 28
  • 1
    If this works like it does in Python, it is simply assigning the same value to two variables (`exports` and `module.exports`) in a single line. – elethan Dec 15 '16 at 18:37

1 Answers1

0

It's just a shortcut to allow you to continue to use exports.[whatever] further down in the file. Ultimately, it's the contents of module.exports that gets "exported".

matpie
  • 17,033
  • 9
  • 61
  • 82