Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(babel-preset-expo, metro-config): Move majority of babel plugin…
…s to babel preset expo (#25461) # Why Metro's default design injects babel plugins across a number of different transformation layers and files. This makes working with Expo/React Native extremely confusing. This PR aims to move the majority of babel-related logic to `babel-preset-expo`. This has the following benefits: - Babel has a standard plugin system, Metro does not, by offloading more transformation to Babel we effectively enable a Babel-based plugin architecture for Expo Metro users. - By moving more of the options to Babel via the caller we can preserve the caching behavior from before but with less fragmentation as we do most config caching in Babel. - Having most the transformations in one place makes it easier to reason about how source must be transformed to work in Expo-supported runtimes. This makes it easier to migrate to other tools like SWC by rewriting babel-preset-expo, as opposed to by rewriting metro-transform-worker, metro-babel-transformer, and metro-babel-preset-react-native. - Fix ENG-10578 This PR also fixes a weird edge case where the import behavior works differently when no babel config exists. We'll do another pass to unify this logic in the future by passing the inlineRequires and transform support as caller options. <!-- Please describe the motivation for this PR, and link to relevant GitHub issues, forums posts, or feature requests. --> # How Consolidate our `transformer.babelTransformerPath` implementation and move the additional babel plugins to `babel-preset-expo`. We also drop the inlineRequires transform which is already applied in the `metro-transform-worker` here https://github.com/facebook/metro/blob/55b45becb1fbb4237ecc5fd0d2c81f199aefe09e/packages/metro-transform-worker/src/index.js#L293-L301 -- this also matches the upstream change facebook/react-native#38771 # Test Plan - Added new tests for the babel transforms. --------- Co-authored-by: Expo Bot <34669131+expo-bot@users.noreply.github.com>
- Loading branch information