Module syntax

Axel Rauschmayer axel at
Mon Jun 3 11:40:04 PDT 2013

> On Mon, Jun 3, 2013 at 1:29 PM, Axel Rauschmayer <axel at> wrote:
> Bikeshedding: I generally like the module syntax, but I’d always omit the braces and use `import default` for importing the default export of a module.
> From the wiki:
> module "foo" {
>   export default function() { console.log("hello!") }
> } 
> ...
> import default;
> What would be the bound name? foo? Am I missing something?

I’d use:
import default foo from "foo";

Thus, the examples in the wiki [1] become:
import default $ from "jquery";                    // import the default export of a module
module crypto from "crypto";               // binding an external module to a variable
import encrypt, decrypt from "crypto"; // binding a module's exports to variables
import encrypt as enc from "crypto";   // binding and renaming one of a module's exports
export * from "crypto";                    // re-exporting another module's exports
export foo, bar from "crypto";         // re-exporting specified exports from another module


Dr. Axel Rauschmayer
axel at


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the es-discuss mailing list