Module naming and declarations

Domenic Denicola domenic at domenicdenicola.com
Wed May 8 10:03:57 PDT 2013


From: Jason Orendorff [jason.orendorff at gmail.com]

> Here's what you would do under the proposal:
>
> ```js
> // import a module in the same package/project
> import "./controllers" as controllers;
>
> // import some other package
> import "backbone" as backbone;
> ```
>
> The surface syntax deliberately follows Node. The first import is relative and the second is absolute, within the tree of module names (not URLs; neither of those module names is a URL).

That is not my understanding of Sam's message at https://mail.mozilla.org/pipermail/es-discuss/2013-May/030553.html. Following those steps for `"backbone"` would, according to that message,

1. Split the module name on "/", url-encode, and re-join (yielding `"backbone"`).
2. Append ".js" to the module name (yielding `"backbone.js"`).
3. Use the URL parser with the  base URL to produce an absolute URL (yielding `"http://example.com/path/to/base/backbone.js"`).
4. Pass the absolute URL to the fetch hook.




More information about the es-discuss mailing list