Skip to content

Transform class static blocks in the Babel preset - #59854

Open
lazerg wants to merge 2 commits into
react:mainfrom
lazerg:fix/issue-59853-class-static-block
Open

lazerg wants to merge 2 commits into
react:mainfrom
lazerg:fix/issue-59853-class-static-block

Conversation

@lazerg

@lazerg lazerg commented Nov 7, 2026

Copy link
Copy Markdown
Contributor

Summary:

@react-native/babel-preset runs the class features plugins (transform-private-methods and transform-private-property-in-object, plus transform-class-properties when classes are lowered) but not @babel/plugin-transform-class-static-block. Those plugins throw "Static class blocks are not enabled" on any class with a static { } block, so an app file or dependency using one fails to bundle. The preset now adds the static block plugin next to the private methods plugin, so it only runs when the class features plugins do. With unstable_preserveClassPrivate the block is still left as is, like before.

Fixes #59853

Changelog:

[GENERAL] [FIXED] - Babel preset no longer fails on class static blocks

Test Plan:

Added tests for a class with a static block under the hermes-stable and hermes-legacy profiles; both fail with "Static class blocks are not enabled" before the change. jest packages/react-native-babel-preset passes and the existing transform snapshots are unchanged. The plugin's ^7.26.0 range is already in yarn.lock, so the lockfile doesn't change.

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Nov 7, 2026
@facebook-github-tools facebook-github-tools Bot added the Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. label Nov 7, 2026

This branch has not been deployed

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

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

@react-native/babel-preset fails on class static blocks: "Static class blocks are not enabled"

1 participant