feat(tools): unified Metro config transformers #162
Merged
+1,016
−89
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 PR introduces a unified Metro config transformer system that provides a consistent, composable way to modify Metro configurations across different export formats (objects, promises, functions, async functions, and promises of functions).
The new system includes:
createMetroConfigTransformer() - A factory function that creates transformers compatible with all Metro config export patterns
composeMetroConfigTransformers() - A Babel-like composition utility for chaining multiple transformers with optional configuration
All existing Metro plugins have been updated to use this unified system, providing better type safety and composability.
Context
Metro configuration in React Native projects can be exported in multiple formats, and existing transformer patterns were inconsistent across plugins. This unified system solves the problem by providing a single abstraction that preserves the "shape" of any Metro config export while applying transformations.
The system is designed to be reusable beyond the Rozenite ecosystem - any Metro-based bundling setup can benefit from this composable transformer pattern.
Testing
A test suite covers all transformer functions. It validates different Metro config export patterns and composition scenarios. The implementation has also been tested in practice by using the playground app with multiple transformers composed together.