refactor(transformer): introduce TransformCtx::duplicate_expression#7754
Merged
graphite-app[bot] merged 1 commit intomainfrom Dec 10, 2024
Conversation
Contributor
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. |
Member
Author
This was referenced Dec 9, 2024
CodSpeed Performance ReportMerging #7754 will not alter performanceComparing Summary
|
Dunqing
approved these changes
Dec 10, 2024
Member
Dunqing
left a comment
There was a problem hiding this comment.
Great! It also can be used in optional-chaining plugin!
Contributor
Merge activity
|
…#7754) Move implementation of `duplicate_object` from the class properties transform into `TransformCtx::duplicate_expression`, so it can also be used in other transforms.
b23adea to
b500f55
Compare
Dunqing
pushed a commit
that referenced
this pull request
Dec 10, 2024
…eds_temp_var` param (#7756) `TransformCtx::duplicate_expression` method introduced in #7754 take a param `mutated_symbol_needs_temp_var`. If `true`, `duplicate_expression` will create a temp var for an `IdentifierReference` whose's symbol is assigned to elsewhere in the AST. If `false`, it won't. This is required because different transforms which use `duplicate_expression` have different requirements.
Dunqing
pushed a commit
that referenced
this pull request
Dec 10, 2024
…Reference`s with `ReferenceId` (#7745) Use `TransformCtx::duplicate_expression` (introduced in #7754) to decide when to create temp vars for member expression object and computed property. This fixes a bug where `IdentifierReference`s created when transforming `key` in `object[key] &&= value` were created without a `ReferenceId` (due to `clone_in`). We didn't catch this before because Babel's test fixtures only cover `object[key++] &&= value` not the simpler `object[key] &&= value`. Add tests for this.
Dunqing
pushed a commit
that referenced
this pull request
Dec 10, 2024
…rals (#7759) `TransformCtx::duplicate_expression` (introduced in #7754) don't create temp vars for literals. This produces more compact output for the logical assignment operators transform. This diverges from Babel (it's better!) so add an override for one of Babel's fixtures. Also add further tests for all literal types.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Move implementation of
duplicate_objectfrom the class properties transform intoTransformCtx::duplicate_expression, so it can also be used in other transforms.