Modules feedback, proposal

Wes Garland wes at page.ca
Sun Apr 1 05:22:36 PDT 2012


On 31 March 2012 21:30, David Herman <dherman at mozilla.com> wrote:

> Yeah, I've thought about auto-appending ".js". I think you're right that
> it opens up the possibility to be a little more abstract.
>

FWIW -- the CommonJS convention of auto-appending .js has been a real boon
to us when writing GPSEE modules.  We took it a step farther, and decided
we should search the filesystem for modules ending in .so also, giving us
the ability to have modules which are written in JS, C/C++, or both --
completely transparently to the JS user.

I am considering allowing modules written in CoffeeScript, and we'll do the
same thing, compiling the CoffeeScript code transparently to a CommonJS
module interface, and again, the JS application developer never needs to
know what language the application is written in.

A similar pattern might be useful if another language on the web ever
emerges which needs to co-exist with ES within the browser -- provided this
new language could present an ES6 module interface, your loader could
detect which compiler to send it to, based on the MIME type, which the web
server would figure out based on the extension which it finds by searching
the filesystem.  You could trivially implement the web-server part today
with Apache's content negotiation stuff.

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/20120401/13f61633/attachment.html>


More information about the es-discuss mailing list