exports at the top of the file

Raul-Sebastian Mihăilă raul.mihaila at gmail.com
Tue Jun 7 04:39:11 UTC 2016

Douglas Crockford said that eventually JSLint would require exports at the
top of the file. However I think there are some issues.

If my understanding is correct,

export default myConst;
const myConst = {};

would throw because when the export is evaluated, in step 2 of the
Evaluation algorithm applied to the ExportDeclaration: export default
AssignmentExpression; production (
the value of the assignment expression is retrieved, which should cause an
error because the binding has not yet been initialized.

I'm not sure what should happen if myConst was exported with an

export {myConst};
const myConst = {};

In this case, the Evaluation algorithm just returns a normal completion.
But I think that it depends on when myConst is indirectly accessed in the
importing modules. If it's accessed before `const myConst` is evaluated,
then I believe it would be uninitialized and would throw. Otherwise, it
would work.

Is my understanding correct? Thanks!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20160607/7e4b30b4/attachment.html>

More information about the es-discuss mailing list