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