Fwd: ES5 Module Systems (was: Alternative proposal to privateName.public)

27 views
Skip to first unread message

Mark S. Miller

unread,
Dec 26, 2011, 5:44:05 PM12/26/11
to comm...@googlegroups.com, nod...@googlegroups.com, Axel Rauschmayer, Jake Verbaten
The following is from the thread at <https://mail.mozilla.org/pipermail/es-discuss/2011-December/019020.html>. If we all agree there is a need for such functionality, then either:

a) We should revise the CJS module spec to accepts "module.exports = ...;"
b) We should revise NodeJS to accept "module.setExports(...);" and accept this proposal into CJS
c) Axel should document his boilerplate pattern as an adapter of AMD only to NodeJS modules, not CJS modules.

My favorite is #b.

---------- Forwarded message ----------
From: Jake Verbaten <ray...@gmail.com>
Date: Mon, Dec 26, 2011 at 2:02 PM
Subject: Re: ES5 Module Systems (was: Alternative proposal to privateName.public)
To: "Mark S. Miller" <eri...@google.com>
Cc: Axel Rauschmayer <ax...@rauschma.de>, es-discuss <es-di...@mozilla.org>


However, I am confused by the "module.exports = ..." part of your boilerplate. The main CommonJS wiki seems down at the moment, but looking at <http://wiki.commonjs.org.mirrors.page.ca/articles/m/o/d/Modules.html> on the mirror site, I could not find any support for this idiom. The closest I could find was <http://wiki.commonjs.org.mirrors.page.ca/articles/m/o/d/Modules_SetExports_9215.html>, which suggests it should read "module.setExports(...);" instead. Where does "module.exports = ..." come from?

module.exports = ... is a mechanism in node.js to overwrite the exports object entirely. (useful when you want to export, say a function rather then an object)

It seems to be similar to module.setExports and is there purely to support the implementation of the module system in node.js



--
    Cheers,
    --MarkM
Reply all
Reply to author
Forward
0 new messages