ES Modules: suggestions for improvement

Wes Garland wes at page.ca
Tue Jul 24 05:13:27 PDT 2012


On 24 July 2012 05:03, Claus Reinke <claus.reinke at talk21.com> wrote:

> Hm, I hadn't thought about that, but my intuition tells me that
> there should be an export object for every module, with just the
> exports, and that this export object should be accessible from the module
> object.
>

Being able to access the export object from the module object enables a
pattern we use locally, which is roughly

require("myModule").configParameter = xyz;

or

require("myModule").errorReporter = function(err){alert(err)};

exports.errorReporter, exports.configParameter are then used heavily within
the module -- normally, they are not even set by the user, but they there
in case the user needs to override some behaviour.

Wes

-- 
Wesley W. Garland
Director, Product Development
PageMail, Inc.
+1 613 542 2787 x 102
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20120724/28f0124f/attachment.html>


More information about the es-discuss mailing list