Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Regression] default class exports #725

Closed
manniL opened this issue Feb 6, 2019 · 5 comments
Closed

[Regression] default class exports #725

manniL opened this issue Feb 6, 2019 · 5 comments
Labels

Comments

@manniL
Copy link

manniL commented Feb 6, 2019

Having the following test.js file:

export default class Test {}

Test.something = 'ok'

will throw an error with esm@3.2.1

node -r esm test.js
file:///home/..../test.js:1
ReferenceError: Test is not defined
at Object. (file:///home/.../test.js:3:1)
at Generator.next ()

but not with esm@3.2.0 nor esm@3.1.4

Originally posted by @manniL in #722 (comment)

@dnalborczyk
Copy link
Contributor

thank you @manniL for bringing this up!

@jdalton seems to be an introduced bug by acorn? https://github.com/acornjs/acorn/blob/master/acorn/CHANGELOG.md#bug-fixes

fwiw, hoisting still works for exported default function declarations:

export default function Test() {}
Test.something = "ok";

somewhat surprised that there isn't a test262 test for this which could have caught this. gonna check over there as well.

@jdalton
Copy link
Member

jdalton commented Feb 6, 2019

Thanks for the report @manniL and thanks for digging in @dnalborczyk!

After review it is not an Acorn issue but an esm issue introduced by this commit 9f8af43.

Update:

Patch 55d92f8; Tests a24a4a9;

@manniL
Copy link
Author

manniL commented Feb 6, 2019

Thanks for the quick fix @jdalton

Credits to @pimlie who noticed the bug while working on a new Nuxt.js feature. 👍

@jdalton
Copy link
Member

jdalton commented Feb 7, 2019

v3.2.2 is released 🎉

@adrianheine
Copy link

We actually had the same issue, see acornjs/acorn#810.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

4 participants