export default and export {foo as default}?

Brendan Eich brendan at mozilla.org
Thu Jan 29 20:12:08 PST 2015


I recall others being confused; probably an informative note in the spec 
would help.

/be

Erik Arvidsson wrote:
> I looked into it in more details and I seem to have been mistaken. 
> "*default*" is just internal spec name that is needed for hoisting 
> FunctionDeclaration and to create the required anonymous binding.
>
> On Thu Jan 29 2015 at 4:20:15 PM Erik Arvidsson 
> <erik.arvidsson at gmail.com <mailto:erik.arvidsson at gmail.com>> wrote:
>
>     It used to be the case that `export default` was just syntactic
>     sugar for exporting something with the name "default".
>
>     export default 42;
>
>     was the same as
>
>     const x = 42;
>     export {x as default};
>
>     More importantly this symmetry was very useful on the import side
>     as well as when reexporting default exports.
>
>     export {default} from './m.js'
>
>     The above line now requires a local binding.
>
>     import tmp from './m.js';
>     export default tmp;
>
>     I don't know why this was changed or if this was discussed anywhere?
>
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss


More information about the es-discuss mailing list