feat(tools-react-native): Add mergeTransformerConfigs function to @rnx-kit/tools-react-native#4044
Open
feat(tools-react-native): Add mergeTransformerConfigs function to @rnx-kit/tools-react-native#4044
Conversation
tido64
reviewed
Mar 25, 2026
…/jasonvmo/rn-metro-utils
Co-authored-by: Tommy Nguyen <4123478+tido64@users.noreply.github.com>
…rosoft/rnx-kit into user/jasonvmo/rn-metro-utils
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description
This adds a utility for merging transformer configurations to tools-react-native to help with transformer merging. I added this as part of a new submodule called metro-utils for general metro utility functions.
I considered various other places for this. The main package it would make sense in is @rnx-kit/metro-config but that isn't a utility package used by other packages in react-native and has issues if you try to include it as a dependency of the cli. Given the already existing utilities for resolving packages from metro it made the most sense to add it to tools-react-native.
The function itself is straightforward and will perform a flat merge (which is what metro does) except if there are multiple getTransformOptions implementations in which case they will be wrapped with the results merged together in order of precedence. This function is used to initialize the babel transformers, it is called once with the results being serialized via json to the metro transformers.
Having the merge function be baked into the CLI is required so that any transform options being set by a transformer configuration don't get stomped by the esbuild transformer which is always added at the end. The esbuild transform options will take precedence still, but things like custom options can still be used in this case.