-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
Check exported bindings are defined #9589
Conversation
Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/10315/ |
@@ -489,7 +489,7 @@ suites.forEach(function(testSuite) { | |||
const actualAst = parse(actualCode, { | |||
filename: actual.loc, | |||
plugins: task.options.plugins || [], | |||
strictMode: false, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was not really correct as sourceType:"module"
should always be in strict mode, but it is needed for some of the tests.
Can I EDIT: Ok, I can't. Can you add a test both for it and |
I was wondering the same while working on it, but node does not allow to export globals either. I will add a test. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In case you are wondering how much confusing it is: https://twitter.com/NicoloRibaudo/status/1100340777262166016 😛
Please take a look at #9745 |
It's fine to use the parser to help enforce spec compliance, as long as you make the behavior configurable, but as far as I can tell there's no way to disable this new and surprising behavior. Babel has a powerful plugin system that allows sophisticated developers to produce valid code even if it looks "wrong" when it's first parsed. If the parser just refuses to parse the code, that power is lost. Please consider making this behavior configurable! If you're open to that idea, I would be happy to submit a PR. |
This ensures that exports are always defined before exporting them. This is required according to the spec here: https://www.ecma-international.org/ecma-262/9.0/index.html#sec-module-semantics-static-semantics-early-errors