Skip to content
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

Conversation

overlookmotel
Copy link
Contributor

@overlookmotel overlookmotel commented Dec 9, 2024

Move implementation of duplicate_object from the class properties transform into TransformCtx::duplicate_expression, so it can also be used in other transforms.

Copy link

graphite-app bot commented Dec 9, 2024

Your org has enabled the Graphite merge queue for merging into main

Add 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.

@github-actions github-actions bot added A-transformer Area - Transformer / Transpiler C-cleanup Category - technical debt or refactoring. Solution not expected to change behavior labels Dec 9, 2024
Copy link

codspeed-hq bot commented Dec 9, 2024

CodSpeed Performance Report

Merging #7754 will not alter performance

Comparing 12-09-refactor_transformer_introduce_transformctx_duplicate_expression_ (b500f55) with main (3c1b2bf)

Summary

✅ 29 untouched benchmarks

Copy link
Member

@Dunqing Dunqing left a 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!

@graphite-app graphite-app bot added the 0-merge Merge with Graphite Merge Queue label Dec 10, 2024
Copy link

graphite-app bot commented Dec 10, 2024

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.
@Dunqing Dunqing force-pushed the 12-09-refactor_transformer_introduce_transformctx_duplicate_expression_ branch from b23adea to b500f55 Compare December 10, 2024 02:28
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
… for `super` (#7757)

`TransformCtx::duplicate_expression` method introduced in #7754 don't create a temp var for `super`. This prepares it for use in logical assignment operator transform (#7745).
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.
@graphite-app graphite-app bot merged commit b500f55 into main Dec 10, 2024
25 checks passed
@graphite-app graphite-app bot deleted the 12-09-refactor_transformer_introduce_transformctx_duplicate_expression_ branch December 10, 2024 02:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0-merge Merge with Graphite Merge Queue A-transformer Area - Transformer / Transpiler C-cleanup Category - technical debt or refactoring. Solution not expected to change behavior
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants