Skip to content

Conversation

@robhogan
Copy link
Contributor

Summary:
unstable_transformProfile is used by Metro to hint at the appropriate set of Babel transforms for the target engine.

To be effective in react-native/babel-preset, it must currently be passed in the preset config.

When the user does not use a custom Babel config, react-native/metro-babel-transformer detects that and auto-configures the preset with options from Metro - that's fine.

But if the user has their own Babel config, building on top of react-native/babel-preset, the preset for the config is fixed - so unstable_transformProfile has no effect.

Ideally, unstable_transformProfile should be a function of the target engine - it's totally reasonable for one instance of Metro to build for multiple engines - so this should instead be passed programmatically to the engine by Metro for each transform job.

Babel provides a mechanism to do this efficiently, without reinitialising the preset unnecessarily, via the caller API.

This passes unstable_transformProfile through caller.

Changelog: [Internal]

(This is part of using a more optimised transform profiles for Hermes V1, which is still an experimental opt-in. When we stabilise Hermes V1 in RN, we should stabilise this API)

Differential Revision: D82625477

…back to it in `@react-native/babel-preset`

Summary:
`unstable_transformProfile` is used by Metro to hint at the appropriate set of Babel transforms for the target engine.

To be effective in `react-native/babel-preset`, it must currently be passed in the preset config.

When the user does not use a custom Babel config, `react-native/metro-babel-transformer` detects that and auto-configures the preset with options from Metro - that's fine.

But if the user has their own Babel config, building on top of `react-native/babel-preset`, the preset for the config is fixed - so `unstable_transformProfile` has no effect.

Ideally, `unstable_transformProfile` should be a function of the target engine - it's totally reasonable for one instance of Metro to build for multiple engines - so this should instead be passed programmatically to the engine by Metro for each transform job.

Babel provides a mechanism to do this efficiently, without reinitialising the preset unnecessarily, via the `caller` API.

This passes `unstable_transformProfile` through `caller`.

Changelog: [Internal]

(This is part of using a more optimised transform profiles for Hermes V1, which is still an experimental opt-in. When we stabilise Hermes V1 in RN, we should stabilise this API)

Differential Revision: D82625477
@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 Dec 23, 2025
@meta-codesync
Copy link

meta-codesync bot commented Dec 23, 2025

@robhogan has exported this pull request. If you are a Meta employee, you can view the originating Diff in D82625477.

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. fb-exported meta-exported p: Facebook Partner: Facebook Partner

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants