4

Are there any build tools or JS-environments that use only the exports-variable and not module.exports, when doing a CommonJS-like require()? (i.e. disregard AMD/RequireJS)

Background
The CommonJS specification only defines the exports variable – it never mentions module.exports – however when most people write about CommonJS1, they assume that it's possible to use module.exports rather than exports, as popularized by Node.js. My general impression is that most so-called "CommonJS" implementations support module.exports.

This is relevant to me as the UMD-template for jQuery-plugins only checks module.exports, whereas most of the other CommonJS UMD-templates actually check the exports-variable (and thus conform to the CommonJS-spec). So which one is it – can I move to fully ignoring exports and only check for module.exports – or do I really need to check exports to have my library support all possible clients?

References
1 dontkry.com, freecodecamp.com, Brian Leroux, various StackOverflow questions

Community
  • 1
  • 1
qff
  • 5,524
  • 3
  • 37
  • 62
  • Perhaps [this](http://stackoverflow.com/a/7142924/2581562) helps: – Legends Dec 27 '16 at 12:29
  • @Legends: Hi – sorry – it doesn't. The question is not about the difference between `exports` and `module.exports`, but rather whether I will ever run in to a situation where `module.exports` is unavailable (and only `exports` is available) – qff Dec 28 '16 at 15:19

0 Answers0