module exports

Kevin Smith zenparsing at gmail.com
Fri Mar 14 09:24:53 PDT 2014


>
>
>   var f = function a() {};
>
>   a(); // nope.
>

Sure, note the equals (which is my point).


>  var D = class C {};
>
> And no one would expect to be able to this:
>
>   var c = new C();
>
>
Same thing. Note the equals, which gives the reader the necessary visual
cue that we are entering an AssignmentExpression context.


> But if you used the `export Declaration` form, it will work (as it does
> today, without `export` of course):
>
>   export class C {}
>   var c = new C();
>
>   export function F() {}
>   var f = new F();
>

Right.  The lack of equals sign shows us that this is clearly a declaration.


>
>> Node users don't elide the equals sign, do they?
>>
>
>>     module.exports = whateva;
>>
>> So why are we?
>>
>
> To make a single form that works across platforms (ie. an amd module
> doesn't "just work" in node and vice versa). I don't think this is strong
> enough to be considered a valid counter-point, I recommend not pursuing it.
> `export default function() {}` will work the same way on all platforms.
>

Sorry, I don't understand this.  ES6 modules, whatever they are, will be
the same across platforms.

And if I believe TC39 is making a mistake, I will pursue it : )
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20140314/c2a2b682/attachment.html>


More information about the es-discuss mailing list