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
Properly parse export default from
when exportDefaultFrom
is not enabled
#11676
Conversation
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit a6138fb:
|
Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/23524/ |
LGTM, but looks like Flow is currently failing the build. |
@@ -0,0 +1 @@ | |||
export default \u{66}rom; |
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.
🤦♂️IMO it should be addressed in the export-default-from proposal that while export default from
is banned, export default \u{66}rom
is still valid.
Related - tc39/proposal-export-default-from#2 |
); | ||
return ( | ||
nextAfterFrom === charCodes.quotationMark || | ||
nextAfterFrom === charCodes.apostrophe |
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.
I don't understand why we need to special-case these two characters and why not, for example (
or *
.
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.
If we see a string literal after from, it is considered a fromClause and thus it is indeed export default fromClause instead of export default AssignmentExpression.
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.
I was reading quaotationMark as questionMark 😁
Co-authored-by: Nicolò Ribaudo <nicolo.ribaudo@gmail.com>
This PR contains two fixes. I include these two because they are highly related and the change should be acceptable to fit in a single PR.
The first fix addresses to
export default from;
whenexportDefaultFrom
is not enabled, which is allowed by the spec. We do a second lookahead after we have seenexport default from
via a newnextTokenStartSince
method, and test if it starts with'
or"
which iff. starts a string literal.The second fix ban
export default from
whenexportDefaultFrom
is enabled, which is forbidden by the spec draft. Though I don't find any detailed explainers but I guess it is to address the following ASI hazard.