Remapping Module URLs

# Kevin Smith (14 years ago)

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 "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 === "code.jquery.com/jquery2.js") return "/local-scripts/jquery2.js"; else return url; } });

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

Is that correct?