simpler, sweeter syntax for modules

Brendan Eich brendan at
Thu Mar 22 16:54:11 PDT 2012

John J Barton wrote:
> If I go back to my previous question, can we understand what should 
> happen here?
> if (version === 1)
>   import y from 'lib1.js';
> else
>   import y from 'lib2.js';

Again, no.

1. We are not breaking run-to-completion by nesting (conditionally on 
control flow) blocking event loops.

2. Also we are not losing static binding by having the names injected by 
static syntactic forms depend on control flow dynamics.

> To me the answer should be that the lib1.js and lib2.js are fetched 
> (because I did not specify async). But they should not be executed (or 
> compiled IMO) until the statement executes. That does not seem to be 
> what Brendan thinks.

Don't break the web.

Seriously, you want something that is not tenable for developers or 
browser implementors. Both 1 and 2 matter. You might argue 2 is not 
important but 1 remains. TC39 wants dynamic things to be dynamic 
(modules reflect when passed to load callbacks as objects with 
properties), and static things to bind statically.


More information about the es-discuss mailing list