module exports

Kevin Smith zenparsing at
Fri Mar 14 06:54:04 PDT 2014

> I'm trying to understand how that compares to ES6 modules. I see how in
> ES6 I can import specific things from a module or I can import everything a
> module exports.

You can't really import all exported bindings.  You can import the module
instance object itself:

    module M from "wherever";

which will give you access to all of the exports.

> Am I correct that a "default" export can be somewhere in the middle ... a
> subset of everything that is exported?

Not really.  The default export is literally just an export named
"default".  There is sugar on the import side, where you can leave off the

    import foo from "somewhere";

is equivalent to:

    import { default as foo } from "somewhere";

The specialized default export syntax is just plain confusing and should be
jettisoned, in my opinion.  It would be less confusing for users to simply

    export { foo as default };

I fail to see why sugar over this form is necessary.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the es-discuss mailing list