I\'ve found the following contract in a Node.js module:
module.exports = exports = nano = function database_module(cfg) {...}
I wonder what
It's a subtle difference to do with the way objects are passed by reference in JavaScript.
exports
and module.exports
both point to the same object. exports
is a variable and module.exports
is an attribute of the module object.
Say I write something like this:
exports = {a:1};
module.exports = {b:12};
exports
and module.exports
now point to different objects. Modifying exports no longer modifies module.exports.
When the import function inspects module.exports
it gets {b:12}