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
[BugFix] Compile export default from #7309
Conversation
Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/6780/ |
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.
- Can you add some tests?
- To avoid using lookahead (which needs to clone the whole Babylon state), we can do something like this:
const declaration = this.parseMaybeAssign();
if (declaration.type === "Identifier" && declaration.value === "from" && this.state.type === tt.string) {
// export default from "module";
} else {
node.declaration = declaration;
return ExportDefaultDeclaration;
}
isDefaultfrom = true; | ||
const lookaheadState = this.lookahead(); | ||
if ( | ||
lookaheadState.value === "=" || |
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.
What if I have another token? e.g. export default from + 2;
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.
Yeah Sorry, didn't consider that.. Will update the PR
I just read the spec and it looks like this is disallowed? 🤔 https://tc39.github.io/proposal-export-default-from/#prod-ExportDeclaration
|
but since it is still in proposal, should i work on this PR or not? like first we should check whether |
For now I think we should wait: even if it is currently allowed, we should prevent users from depending on Usually the spec doesn't includes breaking changes, but since people who are using modules are also using Babel (because native esm support is really new), that change wouldn't break anyone's existing code and thus I think tc39 folks could decide do make it. cc @leebyron I'd like to know your opinion, since you are the author of the proposal 🙂 |
I believe @jdalton has taken over for these. I’m still in support of them, but have not been attending TC39 meetings and don’t know their status |
@nveenjain Although this PR is closed by #11676, I want to thank you for your inspiring work here! |
Now we check in export default statements that if from is either an assignment or from is exported then valid AST are generated, which doesn't require any sort of plugin.