Module naming and declarations

Anne van Kesteren annevk at
Sat May 4 01:12:06 PDT 2013

On Sat, May 4, 2013 at 12:46 AM, Jason Orendorff
<jason.orendorff at> wrote:
> 0. No effort: modules are loaded relative to the document base url,
> with ".js" appended. So `import "jquery"` maps to the relative URL
> "jquery.js".

Isn't that weird? If I have a script at /resources/test which does a
bunch of imports and I use /resources/test from resources /a/b and
/c/d the document base URL will be different for both. (Document base
URL does not work for workers either.)

Appending ".js" also seems very counter to any other API in the
platform and kinda counter web architecture.

> 1. One line of code: you can set the root URL from which all imports
> are resolved. If you set `System.baseURL =
> ""` then `import "jquery"` maps to the URL
> "".
> 2. A few lines: you can use System.ondemand() to set the URL for each
> module you use. If you call
> `System.ondemand({"": "jquery"})`
> then `import "jquery"` maps to the URL you specified (imports for
> modules that aren't in the table will fall back on the loader's
> baseURL).

I thought the import statements had to be first. Does this effectively
require two script elements?


More information about the es-discuss mailing list