-
-
Notifications
You must be signed in to change notification settings - Fork 361
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
refactor(transformer): combine import and usage in JSX transform #3540
refactor(transformer): combine import and usage in JSX transform #3540
Conversation
Your org has enabled the Graphite merge queue for merging into mainAdd the label “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. Join @overlookmotel and the rest of your teammates on |
CodSpeed Performance ReportMerging #3540 will not alter performanceComparing Summary
|
1027b90
to
cbd7c10
Compare
59c75b5
to
6271438
Compare
Merge activity
|
React JSX transform contains some confusing logic (ported directly from Babel) where in automatic mode, imports are inserted in one place, and then used in another. Logic for which imports are needed is duplicated in both places, and it's hard to figure out whether they're in sync or not (I don't think they are in all cases). This PR unifies the logic in one place. Imports are now added as and when they're used. The `Bindings` enum is responsible for creating imports and also holds the state of which "mode" the plugin is working in: 1. Classic 2. Automatic script 3. Automatic module Combining the two choices classic/automatic and script/module into a single enum: 1. clarifies the logic 2. reduces branching 3. reduces lookups on `ReactJsx::options` (which is behind an `Rc` and therefore costly to read from).
cbd7c10
to
4586f0b
Compare
6271438
to
73b7864
Compare
## [0.13.4] - 2024-06-07 ### Features - 5c8e16c coverage: Second transformer build does not print typescript (#3561) (Dunqing) - 646b993 coverage/transformer: Handle @jsx option (#3553) (Dunqing) - a939ddd transformer/typescript: Remove more typescript ast nodes (#3563) (Dunqing) - e8a20f8 transformer/typescript: Remove typescript ast nodes (#3559) (Dunqing) - ee9a215 transformer/typescript: Handle namespace directive correctly (#3532) (Dunqing) ### Bug Fixes - affb2c8 codegen: Print indentation before directive (#3512) (Dunqing) - f6939cb transformer: Store `react_importer` in `Bindings` in JSX transform (#3551) (overlookmotel) - 7982b93 transformer: Correct spans for JSX transform (#3549) (overlookmotel) - c00598b transformer: JSX set `reference_id` on refs to imports (#3524) (overlookmotel) ### Performance - 37cdc13 transformer: Faster checks if JSX plugin enabled (#3577) (overlookmotel) - 9f467b8 transformer: Avoid fragment update where possible (#3535) (overlookmotel) - ac394f0 transformer: JSX parse pragma only once (#3534) (overlookmotel) ### Documentation - 1d3c0d7 span: Add doc comments to `oxc_span::Span` (#3543) (Don Isaac) ### Refactor - f2113ae transformer: Reduce cloning and referencing `Rc`s (#3576) (overlookmotel) - 0948124 transformer: Pass `Rc`s by value (#3550) (overlookmotel) - e4d74ac transformer: Remove `update_fragment` from JSX transform (#3541) (overlookmotel) - 73b7864 transformer: Combine import and usage in JSX transform (#3540) (overlookmotel) - 6978269 transformer/typescript: Replace reference collector with symbols references (#3533) (Dunqing) Co-authored-by: Boshen <Boshen@users.noreply.github.com>
React JSX transform contains some confusing logic (ported directly from Babel) where in automatic mode, imports are inserted in one place, and then used in another.
Logic for which imports are needed is duplicated in both places, and it's hard to figure out whether they're in sync or not (I don't think they are in all cases).
This PR unifies the logic in one place. Imports are now added as and when they're used.
The
Bindings
enum is responsible for creating imports and also holds the state of which "mode" the plugin is working in:Combining the two choices classic/automatic and script/module into a single enum:
ReactJsx::options
(which is behind anRc
and therefore costly to read from).