-
-
Notifications
You must be signed in to change notification settings - Fork 490
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
fix(oxc_transformer): correct generate ThisExpr
and import.meta
in jsx pragma
#7553
Conversation
Your org has enabled the Graphite merge queue for merging into mainAdd the label “0-merge” to the PR and Graphite will automatically add it to the merge queue when it’s ready to merge. Or use the label “hotfix” to add to the merge queue as a hot fix. You must have a Graphite account and log in to Graphite in order to use the merge queue. Sign up using this link. |
This stack of pull requests is managed by Graphite. Learn more about stacking. |
import.meta
in jsx pragma
59ddf22
to
0158063
Compare
0158063
to
657269c
Compare
CodSpeed Performance ReportMerging #7553 will not alter performanceComparing Summary
|
@overlookmotel need your review. |
import.meta
in jsx pragmaThisExpr
and import.meta
in jsx pragma
13be032
to
a784a82
Compare
657269c
to
c36fb3a
Compare
c36fb3a
to
fd6f836
Compare
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.
Sorry to say I see problems.
Also, could you please add a test for import.meta
?
We can make this more performant by changing Pragma
into an enum, to avoid string comparisons on every call to create_expression
. Something like:
enum Pragma<'a> {
/// `createElement`
Single(Atom<'a>),
/// `React.createElement`
Double(Atom<'a>, Atom<'a>),
/// `foo.bar.qux`
Many(Vec<Atom<'a>>),
/// `this`, `this.foo`, `this.foo.bar.qux`
This(Vec<Atom<'a>>),
/// `import.meta`, `import.meta.foo`, `import.meta.foo.bar.qux`
ImportMeta(Vec<Atom<'a>>),
}
In practice, it's going to always be Single
or Double
. All the others are edge cases.
But we can do that optimization in a follow-up.
9014d31
to
db63e45
Compare
4e15836
to
8d4323c
Compare
8ea7a7b
to
62fbc1e
Compare
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.
Thanks for adding the tests.
I've pushed a couple more commits:
- Get rid of the
Box
es increate_arbitrary_length_member_expr_or_ident
. They didn't appear to add anything. - Tweak the tests to make them more explicit.
Merge activity
|
62fbc1e
to
6af8659
Compare
Follow up after #7553. Move tests setup for JSX pragmas into a macro to prevent tests having access to an owned `TraverseCtx`, for safety.
…sion (#7620) #7553 introduced support for some unusual JSX pragmas e.g. `this.foo` and `import.meta.foo`. We want to support these to pass tests, but they're very unlikely to be used in practice. Identify these strange patterns when parsing the pragma (which happens only once per file), and encode them as an enum. The removes expensive string comparisons from `Pragma::create_expression` (which is called for every JSX element), and keeps the path for common cases fast.
No description provided.