Module naming and declarations

Jason Orendorff jason.orendorff at
Wed May 8 09:45:51 PDT 2013

On Tue, May 7, 2013 at 7:21 PM, Domenic Denicola <
domenic at> wrote:

> I think one point that's being hinted at, but not explicitly called out,
> is the confusing nature of `import "foo"` in the proposed scheme. Notably,
> it shares this confusion with AMD, but not with Node.js.
> The problem is that `import "foo"` can mean *either* "import the main
> module for package with name `foo`" *or* "import `foo.js` resolved relative
> to the base URL".
> In AMD, this problem has been a constant headache on projects that I've
> worked on at my jobs. In Node.js, however, `import "foo"` always means the
> former, and never the latter—Node.js has no concept of "base URL." Instead
> it has the option of doing `import "./foo"`, which has different semantics:
> "import `foo.js` relative to the module in which this code is found."

Here's what you would do under the proposal:

    // 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).

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the es-discuss mailing list