Skip to content

Conversation

@kdy1
Copy link
Member

@kdy1 kdy1 commented Jan 22, 2026

This change fixes the static blocks transform to be compatible with the TC39 proposal that would make frozen classes throw when adding private fields.

Closes #10956

Generated with Claude Code

…asses

This change fixes the static blocks transform to be compatible with the
TC39 proposal that would make frozen classes throw when adding private
fields (https://github.com/tc39/proposal-nonextensible-applies-to-private).

When a class has static private properties, trailing static blocks (those
that come after all static fields) are now deferred to execute after the
class definition is complete. This ensures that even if a static block
freezes the class, no new private fields will be attempted to be added
afterward.

Example transformation:
```js
// Input
class C {
  static #foo = 1;
  static { Object.freeze(this); }
}

// Output
var _initStaticBlock0;
class C {
  static #foo = 1;
  static #_ = _initStaticBlock0 = () => {
    Object.freeze(this);
  };
}
_initStaticBlock0.call(C);
```

Closes #10956

Co-authored-by: Donny/강동윤 <[email protected]>
@kdy1 kdy1 added this to the Planned milestone Jan 22, 2026
@kdy1 kdy1 self-assigned this Jan 22, 2026
@changeset-bot
Copy link

changeset-bot bot commented Jan 22, 2026

⚠️ No Changeset found

Latest commit: fa3ab5a

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

Click here to learn what changesets are, and how to add one.

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

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@github-actions
Copy link
Contributor

Binary Sizes

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

Commit: 6c1cde3

@codspeed-hq
Copy link

codspeed-hq bot commented Jan 22, 2026

CodSpeed Performance Report

Merging this PR will degrade performance by 2.62%

Comparing claude/issue-10956-20260122-0322 (fa3ab5a) with main (7313462)

Summary

❌ 3 regressed benchmarks
✅ 182 untouched benchmarks

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

Performance Changes

Benchmark BASE HEAD Efficiency
es/full-target/es2016 654.1 µs 671.7 µs -2.62%
es/full-target/es2017 615.9 µs 631 µs -2.4%
es/full-target/es2018 576.4 µs 588.4 µs -2.04%

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.

Future proofing of static blocks transform

3 participants