Remapping Module URLs

Kevin Smith khs4473 at gmail.com
Fri Aug 19 09:41:20 PDT 2011


Suppose that "jQuery2" is distributed as a single es-next module and I want
to distribute a module that depends on it.  I would expect to be able to
write something like this:

module jQuery2 from "http://code.jquery.com/jquery2.js";

export function whizBang() {
   /* Use jQuery2 */
}

The end user of this module may want to actually load the "jquery2" module
from somewhere else, though (perhaps from a CDN or locally).  If I
understand the module loaders proposal correctly, the user would need to
create a new loader to map the module url:

var MyLoader = SystemLoader.create(SystemLoader.intrinsics, {
    resolve: function(url) {
        if (url === "http://code.jquery.com/jquery2.js")
            return "/local-scripts/jquery2.js";
        else
            return url;
    }
});

MyLoader.load("whiz-bang.js");

Is that correct?

- khs
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20110819/d8896722/attachment.html>


More information about the es-discuss mailing list