Pass unstable_transformProfile through Babel caller API and fall back to it in @react-native/babel-preset
#54967
+28
−7
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary:
unstable_transformProfileis 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-transformerdetects 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 - sounstable_transformProfilehas no effect.Ideally,
unstable_transformProfileshould 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
callerAPI.This passes
unstable_transformProfilethroughcaller.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