Brian Di Palma (2013-04-25T11:00:21.000Z)
github at esdiscuss.org (2013-07-12T02:27:04.248Z)
I've been following es-discuss for a short amount of time. I'm a JS dev working on a significant code base, this biases how I perceive ES6 issues. From my viewpoint by far the most important advancements provided by ES6, eclipsing all others, are modules and classes. This feeling is widely shared among the developers I work with. So I'm somewhat surprised at the lack of response to Andreas email. Firstly I agree with Andreas point about there being an issue with the naming and declaring of modules. > In the original module proposal, modules were declared via ordinary > lexical identifiers, but could also be imported from external sources > denoted by strings. In November, the proposal was changed to use > string-valued "module ids" for both. The motivation was to simplify > the language, and to provide better support for configuration and > concatenation. This seems an odd change to make, a backward one in fact. I presume that the aim of modules is to provide clean scopes/environments, to prevent global state pollution and to aid in structuring/separating code. Therefore you would wish modules to provide an abstract identifier as opposed to a concrete file path string as its identifier. ```js module topLevelNamespace.subNamespace { export MyClass { } } ``` > Nobody would suggest to use file paths in place of variable > identifiers internally. Yet, that is almost exactly what the proposal > does for modules! Indeed. Working on a large code base containing hundreds of JS classes I think it's cleaner to deal with abstract identifiers which to correspond to namespaces as opposed to file locations on disk. > As various discussions show, people want and expect scope chain > behaviour, and for very good reasons: e.g. nesting modules, confining > modules to local scope, convenient local names, etc. Yes. If we create private packages in our frameworks/libraries I see no reason for any end consumer to have access to these internal artifacts. This is all about working with large code bases, privacy and integrity are very helpful in those situations. > (The path semantics is inherited from legacy module frameworks > for JS, such as AMD. It is a fine solution under the constraints that > these frameworks have to operate in -- in particular, the inability to > extend syntax or add new primitives. However, for ES6 most of these > constraints don't apply, and there is no particular reason to limit > the design to making the same compromises.) To produce such a design purely to serve the needs of old module systems seems a poor choice to me. Over time the standard mechanism will eclipse all other module systems even if it provides no upgrade path for the old systems purely because it is the standard system. As long as it is not a totally broken design. The only time I would be willing to invest learning about the old module systems would be when I want to convert an old module to the new system so I can dump the old system. There is far more code that is not using modules than code that is. The focus should be on creating the best possible module system not the best possible system that smoothly accommodates AMD modules! > A custom loader can, in principle, perform arbitrary interpretation or > rewriting of URLs. In particular, this could be used to implement > interop to absolute repository paths a la AMD or Node, e.g. by > interpreting an "amd:" schema for importing AMD modules that are > relative to a separately configured base URL. In other words, you'd > write > > ```js > import M1 from "a/b"; // native ES6 import, relative path > import M2 from "amd:c/d"; // import of AMD module, relative to AMD base URL > ``` Schema handlers for non standard resources seems like an excellent idea. Neat, clean and easy to identify. I would support that, it could also be used to load non JS resources. Thank you Andreas for highlighting these niggles I do hope there is more interest in them then the lack of response indicates.