Skip to content

revert(es/decorators): revert decorator initializer ordering#11901

Merged
kdy1 merged 1 commit into
mainfrom
kdy1/revert-11847-helper-regression
May 27, 2026
Merged

revert(es/decorators): revert decorator initializer ordering#11901
kdy1 merged 1 commit into
mainfrom
kdy1/revert-11847-helper-regression

Conversation

@kdy1
Copy link
Copy Markdown
Member

@kdy1 kdy1 commented May 27, 2026

Description:

Reverts #11847 because the helper changes shipped in @swc/helpers@0.5.22 caused a decorator helper regression.

This restores the previous 2022-03 decorator initializer behavior, removes the regression fixtures added by #11847, reverts the matching external helper source, and adds a patch changeset for the touched Rust crates.

@swc/helpers@0.5.22 has been deprecated on npm with an upgrade note for 0.5.23.

Validation:

  • git submodule update --init --recursive
  • cargo fmt --all
  • cargo test -p swc_ecma_transforms_base
  • cargo test -p swc_ecma_transforms_proposal
  • cargo clippy --all --all-targets -- -D warnings

pnpm --filter @swc/helpers build was also attempted, but local node_modules is not installed in this checkout, so zx was unavailable.

BREAKING CHANGE:

None.

Related issue (if exists):

Reverts #11847

@kdy1 kdy1 requested review from a team as code owners May 27, 2026 06:35
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 27, 2026

🦋 Changeset detected

Latest commit: 3273a08

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@kdy1 kdy1 enabled auto-merge (squash) May 27, 2026 06:40
@kdy1 kdy1 disabled auto-merge May 27, 2026 06:40
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3273a083a7

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread .github/workflows/CI.yml
Comment on lines 418 to +419
- name: Install wasm-pack
# The rustwasm shell installer can crash on GitHub Windows runners after
# installing. Use the npm package so every CI OS follows one install path.
run: npm install -g wasm-pack
run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Keep wasm-pack installation Windows-safe

In the node-test job I checked the matrix above this step and it still runs on windows-latest as well as macOS, so this reinstates the rustwasm shell installer on Windows. The workflow section being reverted explicitly used the npm package because this shell installer can crash on GitHub Windows runners after installing; with this line the Windows node-bindings CI can fail before pnpm build:dev/tests run. Keep the npm-based install here, or gate the shell installer to non-Windows runners.

Useful? React with 👍 / 👎.

Comment on lines +2398 to +2402
&& i + 1 < body_len
&& matches!(
&n.body[i + 1],
ClassMember::Method(m) if m.kind == MethodKind::Getter
)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Avoid treating source private fields as accessor backing

For 2022-03 classes, this predicate now accepts any initialized private field immediately followed by a public getter, not just the dummy private storage synthesized for auto-accessors. In a class with an instance decorator that creates _initProto and a source #field = ...; get x() { ... }, _initProto(this) is injected into the #field initializer instead of falling back to the constructor, so addInitializer callbacks can run while that private field is still being initialized and throw or observe the wrong order when they access it. Restore the dummy-span plus getter/setter backing-storage checks that were removed here.

Useful? React with 👍 / 👎.

Comment thread .github/workflows/CI.yml
# without the repository-scoped GitHub token, which GitHub can reject
# when fetching an unadvertised submodule commit directly by SHA.
run: git submodule update --init --force --depth=1
submodules: true
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Keep submodule fetches outside checkout

This same submodules: true replacement appears in the cargo-clippy, cargo-check, and cargo-test checkout steps, but the removed step explicitly fetched public submodules after checkout so they were not fetched with the repository-scoped GitHub token. Moving submodule initialization back into actions/checkout reintroduces the unadvertised-submodule-SHA failure mode that comment was guarding against, causing these CI jobs to fail before running Rust checks when a public submodule commit cannot be fetched via the workflow token.

Useful? React with 👍 / 👎.

Comment on lines +2399 to +2402
&& matches!(
&n.body[i + 1],
ClassMember::Method(m) if m.kind == MethodKind::Getter
)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Preserve private auto-accessor initializer order

This 2022-03 backing-field check now only recognizes a public getter after the synthesized storage field, so private auto-accessors (whose generated accessors are ClassMember::PrivateMethod) no longer get _initProto injected into the backing-field initializer. In the ES2015 output for a class with only decorated private accessors, the generated _init_a(this) field initialization now runs before _initProto(this), which reverses the existing ordering tests' expectation that accessor addInitializer callbacks run before accessor init effects. Include the private getter/setter pattern here as well.

Useful? React with 👍 / 👎.

@kdy1 kdy1 merged commit a3f23b1 into main May 27, 2026
101 checks passed
@kdy1 kdy1 deleted the kdy1/revert-11847-helper-regression branch May 27, 2026 06:44
@github-actions github-actions Bot added this to the Planned milestone May 27, 2026
@codspeed-hq
Copy link
Copy Markdown

codspeed-hq Bot commented May 27, 2026

Merging this PR will not alter performance

✅ 189 untouched benchmarks
⏩ 120 skipped benchmarks1


Comparing kdy1/revert-11847-helper-regression (3273a08) with main (3f1a4f5)2

Open in CodSpeed

Footnotes

  1. 120 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant