Ambiguity with default exports and live bindings?

Bergi a.d.bergi at
Wed Jul 6 23:38:38 UTC 2016

/#!/JoePea schrieb:
> Is it true one of the following does not create a live binding?

Yes and no.

> ```js
> let A = 123
> export default A // not a live binding?
> ```

Actually it does create a live binding - to the variable with the name 
"*default*" which you cannot assign. But yes, the binding `A` is not 

> ```js
> let A = 123
> export {A as default} // live binding?
> ```


> If so, this seems like large source for unexpected behavior when people
> create modules. I can imagine people easily overlooking the difference and
> expecting live bindings in both cases (this already happened to me).

I think people do in general not expect live bindings at all. For 
declarations and the purpose of initialisation order, yes, but not for 
mutable variables. You should export `const`s.
See also

Kind regards,

More information about the es-discuss mailing list