Modules Loader.load function

Sam Tobin-Hochstadt samth at
Fri Jun 21 15:13:56 PDT 2013

On Fri, Jun 21, 2013 at 6:00 PM, Guy Bedford <guybedford at> 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
> 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.


More information about the es-discuss mailing list