Skip to content

Conversation

@Dunqing
Copy link
Member

@Dunqing Dunqing commented Aug 20, 2025

Fixes: #13215 (review)

Collect metadata and store them in a VecDeque, and take them when transforming the class decorators in the exit_class side, which can eliminate the unreliable check of span.is_unspanned for metadata decorators. However, it introduces a little complexity.

@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 Aug 20, 2025
Copy link
Member Author

Dunqing commented Aug 20, 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.

@Dunqing Dunqing changed the title refactor(transformer/decorator): eliminate unreliable identification of metadata refactor(transformer/legacy-decorator): eliminate unreliable identification of metadata Aug 20, 2025
@codspeed-hq
Copy link

codspeed-hq bot commented Aug 20, 2025

CodSpeed Instrumentation Performance Report

Merging #13227 will not alter performance

Comparing 08-20-refactor_transformer_decorator_eliminate_unreliable_identification_of_metadata (e7a49ed) with main (a9182f7)1

Summary

✅ 34 untouched benchmarks

Footnotes

  1. No successful run was found on main (e7a49ed) during the generation of this report, so a9182f7 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

@Dunqing Dunqing force-pushed the 08-20-refactor_transformer_decorator_eliminate_unreliable_identification_of_metadata branch from 16f8e20 to 3c27130 Compare August 20, 2025 08:07
@Dunqing Dunqing marked this pull request as ready for review August 24, 2025 04:09
Copilot AI review requested due to automatic review settings August 24, 2025 04:09
@Dunqing Dunqing requested a review from overlookmotel as a code owner August 24, 2025 04:09
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR refactors the legacy decorator metadata handling by replacing unreliable span-based identification with a proper collection and storage system. Instead of checking span.is_unspanned() to identify metadata decorators, the code now collects metadata in a VecDeque during class traversal and retrieves it when transforming class decorators.

  • Introduces a VecDeque-based metadata storage system using NonEmptyStack
  • Replaces span-based metadata decorator identification with proper collection/retrieval
  • Adds support for constructor parameter metadata handling

Reviewed Changes

Copilot reviewed 5 out of 6 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
crates/oxc_transformer/src/decorator/legacy/metadata.rs Implements the new metadata collection system with VecDeque storage and MethodMetadata enum
crates/oxc_transformer/src/decorator/legacy/mod.rs Updates decorator transformation logic to use the new metadata retrieval system
tasks/transform_conformance/tests/legacy-decorators/test/fixtures/oxc/metadata/params/input.ts Adds test case with constructor parameter decorator
tasks/transform_conformance/tests/legacy-decorators/test/fixtures/oxc/metadata/params/output.js Expected output for the new test case
tasks/transform_conformance/snapshots/oxc.snap.md Updates test snapshots to reflect the new behavior

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@Boshen Boshen added the 0-merge Merge with Graphite Merge Queue label Aug 24, 2025
Copy link
Member

Boshen commented Aug 24, 2025

Merge activity

…cation of metadata (#13227)

Fixes: #13215 (review)

Collect metadata and store them in a `VecDeque`, and take them when transforming the class decorators in the `exit_class` side, which can eliminate the unreliable check of `span.is_unspanned` for metadata decorators. However, it introduces a little complexity.
@graphite-app graphite-app bot force-pushed the 08-20-refactor_transformer_decorator_eliminate_unreliable_identification_of_metadata branch from 3c27130 to e7a49ed Compare August 24, 2025 08:36
@graphite-app graphite-app bot merged commit e7a49ed into main Aug 24, 2025
24 checks passed
@graphite-app graphite-app bot deleted the 08-20-refactor_transformer_decorator_eliminate_unreliable_identification_of_metadata branch August 24, 2025 08:42
@graphite-app graphite-app bot removed the 0-merge Merge with Graphite Merge Queue label Aug 24, 2025
graphite-app bot pushed a commit that referenced this pull request Sep 11, 2025
…or parameter decorators (#13632)

Fixes rolldown/rolldown#6079. Regressed introduced by #13227.

The root cause is that the class plugin will insert a constructor method in some cases, but metadata handling is processed before the constructor is inserted, which causes the method count not to be exactly the same as the method metadata count. Thus, decorator metadata is inserted in the incorrect place.

This PR refactors the core transformation logic to ensure that the new methods and properties inserted by other plugins won't affect the decorator transformation.

### Transformation Flow Changes

  Before: Complex upfront analysis with separate processing paths
  - Used check_class_has_decorated() to analyze entire class tree
  - Separate handling for class vs element decorators
  - Multiple disconnected stacks for state tracking

  After: Unified incremental processing
  - Process decorators as we traverse (exit_method_definition,
  exit_property_definition, etc.)
  - Accumulate decoration statements in single stack during traversal
  - Unified processing in transform_class() using consolidated state
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.

3 participants