Modules Loader.load function
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
andLoader.load
.Loader.import
seems to apply the full normalization process, whileLoader.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 jorendorff/js-loaders/blob/master/loaders.js#L142 it seems that any
import
statements in code loaded withLoader.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 theLoader.load
, and if so, why is thetype
metadata in the translate and link hooks necessary? Surely the lack of anormalized
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.
I see there are now two load functions for the ES6 module loader -
Loader.import
andLoader.load
.Loader.import
seems to apply the full normalization process, whileLoader.load
takes a url directly. This sounds like a good feature to me.From the code comments in the reference loader at jorendorff/js-loaders/blob/master/loaders.js#L142 it seems that any
import
statements in code loaded withLoader.load
will still be respected.I was wondering if
export
statements would similarly cause a module to be returned by theLoader.load
, and if so, why is thetype
metadata in the translate and link hooks necessary? Surely the lack of anormalized
property in the metadata would implicitly indicate this anyway?