Add "babelRCPath" transformer option for custom Babel config #962
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
👋 Hello!
I'm so intrigued by the fact that more and more people are trying to use React Native and Next.js together. Libraries like Solito and Tamagui make it so much easier!
The most popular way is to use a monorepo with basically two apps, one with React Native and one with Next.js. However, I kept experimenting with everything in one app, no monorepo (just like Expo). The only issue I experienced so far is with the
babel.config.js
. While Next.js uses SWC, if there is ababel.config.js
file on the root project, it will gracefully fall back to Babel. I hoped to find Next.js to implement a similar option to Metro's enableBabelRCLookup, but no luck. For this reason I need this transformer option to pass in a custom Babel config, so only Metro will pick it up, but not Next.js.I believe this could be helpful for other scenarios as well.
Note: Jest also supports this:
Test plan
I've built a template called 🌘 Luna to demonstrate this implementation by using a
babel.config.native.js
. I'm usingpatch-package
to apply those changes and everything seems fine so far?Steps to test it:
npx react-native init MyAppName
metro.config.js
:babel.config.js
tobabel.config.native.js
.yarn start --reset-cache
EDIT:
I just found out that Next.js actually has an experimental option to fix this, so I can actually try that out, however I would be very happy to contribute if those changes are relevant.