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

Axel Rauschmayer axel at rauschma.de
Mon Dec 26 14:07:49 PST 2011


> IMHO, the best option is still boilerplate (to conditionally turn an AMD into a Node.js module):
>     ({ define: typeof define === "function"
>         ? define
>         : function(A,F) { module.exports = F.apply(null, A.map(require)) } }).
>     define([ "./module1", "./module2" ],
>         function (module1, module2) {
>             return ...
>         }
>     );
> 
> [1] http://www.2ality.com/2011/11/module-gap.html
> 
> 
> I like this adapter, and have just changed <http://code.google.com/p/es-lab/source/browse/trunk/src/ses/amdTest3.js> to test that it works with our simple AMD Loader in translation-free SES-on-ES5 (similar to the above, at <http://code.google.com/p/es-lab/source/browse/trunk/src/ses/makeSimpleAMDLoader.js>). You can run this test by visiting <http://es-lab.googlecode.com/svn/trunk/src/ses/explicit.html> in a modern browser. If you see the line "AMD loader test...succeeded", then it did.

As an aside, one benefit of the above boilerplate is that it is just a prefix (easier to copy and paste than solutions that are wrapped around an AMD).

-- 
Dr. Axel Rauschmayer
axel at rauschma.de

home: rauschma.de
twitter: twitter.com/rauschma
blog: 2ality.com



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20111226/0f1e4aa9/attachment-0001.html>


More information about the es-discuss mailing list