ES Modules: suggestions for improvement

Brendan Eich brendan at
Wed Jun 27 01:31:06 PDT 2012

David Bruant wrote:
> Le 26/06/2012 16:44, David Bruant a écrit :
>> Also relevant to this thread, post on the same topic by Isaacs 
>> (node.js lead) :
> "Furthermore, |let| already gives us destructuring assignment. If a 
> module exports a bunch of items, and we want several of them, then do 
> |var {x,y,z} = import 'foo'| or some such."
> => Excellent idea. That combined with the single export idea reduces 
> the amount of new syntax to introduce.

Declarations can nest under control flow constructs, but import or 
module dependencies must be prefetched. They're static.

   if (some_rare_condition()) { let x = import "m"; ... }

either always prefetches "m", which does not say what is meant; or it 
nests an event loop, violating run-to-completion, which is not going to 

> The Module proposal has a local renaming feature which I think should 
> be kept:
> Initial proposal:
>     import { draw: drawShape } from shape;
>     import { draw: drawGun } from cowboy;
> Could become:
>     let {draw: drawShape} = import './shape.js'
>     let {draw: drawGun} = import './cowboy.js'
> I would actually reverse the order:
>     let {drawShape: draw} = import './shape.js'
>     let {drawGun: draw} = import './cowboy.js'
> But that's a matter of taste.

No, you can't so reorder, it's not a matter of taste. Destructuring is 
the dual <> of 


More information about the es-discuss mailing list