Skip to content

fix(decorators): scope 2023-11 implicit-global rewrite to decorator-lifted exprs#11743

Draft
kdy1 wants to merge 2 commits intomainfrom
kdy1/fix-11742-decorator-globalthis-regression
Draft

fix(decorators): scope 2023-11 implicit-global rewrite to decorator-lifted exprs#11743
kdy1 wants to merge 2 commits intomainfrom
kdy1/fix-11742-decorator-globalthis-regression

Conversation

@kdy1
Copy link
Member

@kdy1 kdy1 commented Mar 27, 2026

Summary

Fixes #11742.

This change scopes the 2023-11 implicit-global rewrite to only decorator-related lifted/reordered expressions.

  • remove the global implicit-global rewrite branch from DecoratorPass::visit_mut_expr
  • add an expression-local rewriter (ImplicitGlobalUsageRewriter) for unresolved assignment/reference rewriting to globalThis
  • apply the local rewriter only at 2023-11 decorator lifting points (super aliasing, decorator expression preservation, computed key pre-init)
  • keep 2022-03 behavior unchanged
  • add regression fixtures for:
    • decorator proposal fixture (2023-11-misc/no-decorators-unbound-assignment)
    • swc projects fixture (issues-11xxx/11742)

Test

  • git submodule update --init --recursive
  • UPDATE=1 cargo test -p swc_ecma_transforms_proposal
  • cargo test -p swc_ecma_transforms_proposal
  • cargo test -p swc --test projects -- issues-11xxx/11742 (filter matched 0 tests)
  • cargo test -p swc --test projects fixture_tests__fixture__issues_11xxx__11742__input -- --ignored
  • cargo fmt --all
  • cargo clippy --all --all-targets -- -D warnings

@changeset-bot
Copy link

changeset-bot bot commented Mar 27, 2026

🦋 Changeset detected

Latest commit: 84ff3e8

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

@github-actions
Copy link
Contributor

Binary Sizes

File Size
swc.linux-x64-gnu.node 28M (29077192 bytes)

Commit: bce39b2

@codspeed-hq
Copy link

codspeed-hq bot commented Mar 27, 2026

Merging this PR will not alter performance

✅ 219 untouched benchmarks


Comparing kdy1/fix-11742-decorator-globalthis-regression (84ff3e8) with main (8d36f05)1

Open in CodSpeed

Footnotes

  1. No successful run was found on main (6f72c47) during the generation of this report, so 8d36f05 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.

decoratorVersion: "2023-11" rewrites top-level assignments to unbound identifiers to globalThis

1 participant