Module naming and declarations

Domenic Denicola domenic at domenicdenicola.com
Wed May 8 11:35:27 PDT 2013


From: samth0 at gmail.com [samth0 at gmail.com] on behalf of Sam Tobin-Hochstadt [samth at ccs.neu.edu]

> There's a default place to fetch files from, because there has to be _some_ default.

Why?

This is the core of my problem with AMD, at least as I have used it in the real world with RequireJS. You have no idea what `require("string")` means---is `"string"` a package or a URL relative to the base URL? It can be either in RequireJS, and it sounds like that would be the idea here. Super-confusing!

I think it would be better if `import "string"` simply did not work by default (threw an error at the resolution stage, for example), unless a named module was already loaded with that name. Then the only behavior that would work by default, when not using named modules, is relative module names, and maybe absolute URLs (URIs?).

This would make it much clearer that `import "string"` is the purview of named modules (= concatenated builds) or custom resolve hooks. When reading code that does `import "backbone"`, you would know the string `"backbone"` has meaning only from some external agency, and is not something you should go hunt around on disk for next to your index.html.



More information about the es-discuss mailing list