module exports
Rick Waldron
waldron.rick at gmail.com
Fri Mar 14 10:06:28 PDT 2014
On Fri, Mar 14, 2014 at 12:24 PM, Kevin Smith <zenparsing at gmail.com> wrote:
>
>> 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.
>
What about the following:
Functions with return AssignmentExpression that include "=" and without--are
the ones without also confusing without the "necessary" visual cue?
function a() {
var F;
return F = function() {};
}
function b() {
var C;
return C = class {};
}
vs.
function c() {
return function F() {};
}
function d() {
return class C {};
}
Or yield in generators?
function * a() {
var F;
yield F = function F() {};
}
function * b() {
var C;
yield C = class C {};
}
vs.
function * c() {
yield function F() {};
}
function * d() {
yield class C {};
}
>
>
>> 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.
>
Isn't that exactly what I said? You asked "So why are we?", I answered "To
make a single form that works across platforms" and added that amd and cjs
don't "just work" together. Then I concluded by with a specific example,
but surely that wasn't too misleading?
Rick
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20140314/5a45aec2/attachment.html>
More information about the es-discuss
mailing list