module exports

Mark Volkmann r.mark.volkmann at
Fri Mar 14 07:07:59 PDT 2014

On Fri, Mar 14, 2014 at 8:54 AM, Kevin Smith <zenparsing at> wrote:

>> 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.

That's what I meant by importing all the exports.
I'd prefer it if the syntax for that was

import M from "wherever";

That way I could think of import is doing something like destructuring
where the other syntax below is just getting some of the exports.

import {foo, bar} from "wherever"';

>> 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
> braces:
>     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 write:
>     export { foo as default };
> I fail to see why sugar over this form is necessary.

I completely agree. Plus if this is taken away then the "import" keyword
can be used to get the whole module as in my example above. At that point
maybe there is no need for the "module" keyword.

R. Mark Volkmann
Object Computing, Inc.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the es-discuss mailing list