Dynamic Modules Questions

Sam Tobin-Hochstadt samth at ccs.neu.edu
Wed Mar 6 14:31:47 PST 2013


On Wed, Mar 6, 2013 at 9:46 AM, Kevin Smith <khs4473 at gmail.com> wrote:
> (Referencing the module loaders proposal at
> http://wiki.ecmascript.org/doku.php?id=harmony:module_loaders)
>
> 1)  Loaders have a "strict" flag which indicates whether code evaluated in
> the Loader's context should be implicitly strict.  If modules themselves are
> implicitly strict, is this flag superfluous?

myLoader.eval(someJS) is just like regular `eval`, and also loaders
handle `eval` called from inside them.  So no, the flag isn't
superfluous.

>
> 2)  What is the nature of the bindings created with the Module constructor?
> In the following scenario, what is output?
>
>     var a = 123;
>     var M = new Module({ a: a });
>
>     a = 456;
>     console.log(M.a === a); // bound to "var a" or a new binding?

This logs `false`.

> 3) There doesn't appear to be a way to provide a dynamically created module
> instance (created via the Module constructor) as the result of the fetch
> hook.  My thought is that such a feature might be useful for implementing
> dynamically linked binary add-on modules in server environments.

This is a good thought, and one we've considered.  Note that you can
simply dynamically add the module using `System.set` during the fetch
hook.  We may have more to say about a simpler API for this case in a
little while.

Sam


More information about the es-discuss mailing list