A few more questions about the current module proposal

Kevin Smith khs4473 at gmail.com
Thu Jul 5 05:56:38 PDT 2012

> Will heterogenous transpiling in a web app be supported? Can a JS
> module depend on a CoffeeScript file, and vice versa?

Right - Sam's example of having a specific CoffeeScript loader isn't going
to actually work for this reason.  Instead, we'd have to figure out which
"to-JS" compiler to use inside of the translate hook.

    let maybeCoffeeLoader = new Loader(System, {

      translate(src, relURL, baseURL, resolved) {

        // If file extension is ".coffee", then use the coffee-to-js
        if (extension(relURL) === ".coffee")
          src = coffeeToJS(src);

        return src;


You could use the resolve hook in concert with the translate hook to create
AMD-style plugin directives.  It looks pretty flexible to me.

One question, though:  branching on the file extension, as above, will not
generally work.  The source code might be served through a URL that does
not have a file extension.  On the web though, we'll generally have access
to a Content-Type header.  In the current design, there's doesn't appear to
be a way to get that information.

One possibility for getting the Content-Type header would be to override
the fetch hook and use cross-domain XHR, but that seems like a lot of
duplicated code just to get data that's already being received by the


- Kevin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20120705/97aa46bf/attachment.html>

More information about the es-discuss mailing list