Sam Tobin-Hochstadt (2013-06-21T22:13:56.000Z)
github at esdiscuss.org (2013-07-12T02:27:37.741Z)
On Fri, Jun 21, 2013 at 6:00 PM, Guy Bedford <guybedford at googlemail.com> wrote: > I see there are now two load functions for the ES6 module loader - > `Loader.import` and `Loader.load`. `Loader.import` seems to apply the full > normalization process, while `Loader.load` takes a url directly. This sounds > like a good feature to me. These are different in other, more important ways as well. In particular, `Loader.import` references a module name, (potentially) fetches it, defines the relevant module, and returns the module instance object to the callback, whereas `Loader.load` is basically the (async) composition of XHR and `Loader.evalAsync`. > From the code comments in the reference loader at > https://github.com/jorendorff/js-loaders/blob/master/loaders.js#L142 it > seems that any `import` statements in code loaded with `Loader.load` will > still be respected. Yes, `.load()` is like `.evalAsync()`. > I was wondering if `export` statements would similarly cause a module to be > returned by the `Loader.load`, and if so, why is the `type` metadata in the > translate and link hooks necessary? Surely the lack of a `normalized` > property in the metadata would implicitly indicate this anyway? Using `export` at the top level of code passed to `Loader.load` is a syntax error, the same way it would be a syntax error to use `export` at the top level of any other script.