esm
esm copied to clipboard
Exporting a hoisted var-declared variable causes syntax error
if (true) {
var x = 1;
}
export { x };
This piece of code works with node --experimental-modules on v12.8.0. On esm v3.2.25, it fails with the following error:
export { x };
^
SyntaxError: Export 'x' is not defined in module
Expected behaviour is that this should be considered valid syntax and exported value should have value of 1.
It looks like the assumption here that the exported names should have a top level declaration is wrong.