Skip to content

Conversation

@Dunqing
Copy link
Member

@Dunqing Dunqing commented Apr 1, 2025

close: #10147

Since class-properties will transform the class first, which causes the property will transform into defineProperty(xxx) and insert in the constructor. This results in the decorators being lost. This PR splits the logic into two parts, one part used to transform decorators in exit_class, which runs before class-properties transformation. The other part is to transform class A {} into let A = class A {} in exit_statement.

Copy link
Member Author

Dunqing commented Apr 1, 2025


How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • 0-merge - adds this PR to the back of the merge queue
  • hotfix - for urgent hot fixes, skip the queue and merge this PR next

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

This stack of pull requests is managed by Graphite. Learn more about stacking.

@github-actions github-actions bot added the A-transformer Area - Transformer / Transpiler label Apr 1, 2025
@github-actions github-actions bot added the C-cleanup Category - technical debt or refactoring. Solution not expected to change behavior label Apr 1, 2025
@Dunqing Dunqing changed the title refactor(transformer/legacy-decorator): split the transforming decorated class into two parts and run them in exit_class and exit_statement respectively refactor(transformer/legacy-decorator): split the transforming decorated class into two parts and run them in exit_class and exit_statement respectively Apr 1, 2025
@codspeed-hq
Copy link

codspeed-hq bot commented Apr 1, 2025

CodSpeed Instrumentation Performance Report

Merging #10153 will degrade performances by 3.41%

Comparing 04-01-refactor_transformer_legacy-decorator_split_the_transforming_decorated_class_into_two_parts_and_run_them_in_exit_class_and_exit_statement_respectively (e4029b8) with main (aba3654)

Summary

⚡ 1 improvements
❌ 1 regressions
✅ 34 untouched benchmarks

⚠️ Please fix the performance issues or acknowledge them on CodSpeed.

Benchmarks breakdown

Benchmark BASE HEAD Change
formatter[antd.js] 7.9 ms 7.6 ms +3.88%
formatter[typescript.js] 7.2 ms 7.4 ms -3.41%

@Dunqing Dunqing force-pushed the 04-01-refactor_transformer_legacy-decorator_split_the_transforming_decorated_class_into_two_parts_and_run_them_in_exit_class_and_exit_statement_respectively branch from 5512f31 to 413b69d Compare April 1, 2025 03:55
@Dunqing Dunqing marked this pull request as ready for review April 1, 2025 04:05
@Dunqing Dunqing requested a review from overlookmotel as a code owner April 1, 2025 04:05
@graphite-app graphite-app bot added the 0-merge Merge with Graphite Merge Queue label Apr 1, 2025
@graphite-app
Copy link
Contributor

graphite-app bot commented Apr 1, 2025

Merge activity

…ted class into two parts and run them in `exit_class` and `exit_statement` respectively (#10153)

close: #10147

Since `class-properties` will transform the class first, which causes the property will transform into `defineProperty(xxx)` and insert in the constructor. This results in the decorators being lost. This PR splits the logic into two parts, one part used to transform decorators in `exit_class`, which runs before class-properties transformation. The other part is to transform `class A {}` into `let A = class A {}` in `exit_statement`.
@graphite-app graphite-app bot force-pushed the 03-31-test_transformer_legacy-decorator_enable_class-properties_plugin_for_class-related_tests branch from 1259d7e to 8c296f7 Compare April 1, 2025 05:31
@graphite-app graphite-app bot force-pushed the 04-01-refactor_transformer_legacy-decorator_split_the_transforming_decorated_class_into_two_parts_and_run_them_in_exit_class_and_exit_statement_respectively branch from 413b69d to e4029b8 Compare April 1, 2025 05:32
Base automatically changed from 03-31-test_transformer_legacy-decorator_enable_class-properties_plugin_for_class-related_tests to main April 1, 2025 05:42
@graphite-app graphite-app bot removed the 0-merge Merge with Graphite Merge Queue label Apr 1, 2025
@graphite-app graphite-app bot merged commit e4029b8 into main Apr 1, 2025
27 checks passed
@graphite-app graphite-app bot deleted the 04-01-refactor_transformer_legacy-decorator_split_the_transforming_decorated_class_into_two_parts_and_run_them_in_exit_class_and_exit_statement_respectively branch April 1, 2025 05:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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.

transformer: when using field + legacy decorator + target: 'es2021', the decorator code is not output

2 participants