-
-
Notifications
You must be signed in to change notification settings - Fork 485
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): introduce TransformCtx::duplicate_expression
#7754
refactor(transformer): introduce TransformCtx::duplicate_expression
#7754
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. |
CodSpeed Performance ReportMerging #7754 will not alter performanceComparing Summary
|
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.
Great! It also can be used in optional-chaining
plugin!
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
…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.
…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.
…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.
Move implementation of
duplicate_object
from the class properties transform intoTransformCtx::duplicate_expression
, so it can also be used in other transforms.