On Fri, Mar 14, 2014 at 10:07 AM, Mark Volkmann
<r.mark.volkm...@gmail.com>wrote:

> On Fri, Mar 14, 2014 at 8:54 AM, Kevin Smith <zenpars...@gmail.com> 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";
>

As Kevin said, this already means "import the default export 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.
>>
>
Because it doesn't allow for the Assignment Expression form (specifically,
function expressions) that developers expect to be able to write:

  export default function() {}

Rick
_______________________________________________
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to