feat(metro-serializer-esbuild): Enhance configurability of metro-serializer-esbuild#4009
Draft
feat(metro-serializer-esbuild): Enhance configurability of metro-serializer-esbuild#4009
Conversation
…sformer dynamically
… for both serialization and transformation
tido64
requested changes
Mar 5, 2026
Member
There was a problem hiding this comment.
I am going to have to reject this change and here is why:
- The configuration provided by this plugin are required for esbuild to function at all. We cannot modify any of them. This is why all the tests are failing.
- The problem with this configuration is that it also breaks Metro's dev server. If you want tree shaking, use this serializer and the provided configuration. Otherwise, use none of them.
- This is why we encourage using
@rnx-kit/cli. It does all of this behind the scenes. - If you know what you're doing and want to make changes anyway, you should use the spread operator instead. There is no need for a factory pattern here.
module.exports = makeMetroConfig({ serializer: { customSerializer: MetroSerializer(), }, transformer: { ...esbuildTransformerConfig, babelTransformerPath: require.resolve('react-native-svg-transformer'), }, });
Collaborator
Author
I added the transformer code so you can see what that looks like. I will make a separate package for the transformer but I'm using this to test it in fluentui-react-native as the bundle time shot way up when bundling from typescript instead of JS. |
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 is a precursor change for adding the ability to have esbuild handle front-end transformation in addition to serialization. For this to happen, the serializer and transformer steps need to be configured together. To make that change easier this PR does the following:
MetroEsbuildFactorythat is called with a configuration and returnsmakeSerializerandmakeTransformerfunctions.