babel-plugin-module-resolver doesn't work with react-native 0.63.0+ for iOS production builds
See original GitHub issueDescription
In my react-native project I’m using babel-plugin-module-resolver plugin to achieve relative short path for the modules, files, directories. When I mograted from react-native@0.62
to react-native@0.63
I found that iOS Production build cannot be assembled. Xcode throws Error 65 during build with Fastlane on CI. Manually locally in Xcode it throws the same error for Production builds. Development builds work fine.
After debugging I found that relative paths cannot be resolved correctly in react-native@0.63
. Reverted to 0.62 version -works fine…
React Native version:
System:
OS: macOS 10.15.6
CPU: (8) x64 Intel(R) Core(TM) i7-7700HQ CPU @ 2.80GHz
Memory: 197.68 MB / 16.00 GB
Shell: 5.7.1 - /bin/zsh
Binaries:
Node: 14.5.0 - /usr/local/bin/node
Yarn: 1.22.4 - /usr/local/bin/yarn
npm: 6.14.7 - /usr/local/bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
SDKs:
iOS SDK:
Platforms: iOS 13.6, DriverKit 19.0, macOS 10.15, tvOS 13.4, watchOS 6.2
Android SDK: Not Found
IDEs:
Android Studio: 4.0 AI-193.6911.18.40.6626763
Xcode: 11.6/11E708 - /usr/bin/xcodebuild
Languages:
Java: 1.8.0_252 - /usr/bin/javac
Python: 2.7.16 - /usr/bin/python
npmPackages:
@react-native-community/cli: Not Found
react: 16.13.1 => 16.13.1
react-native: 0.63.2 => 0.63.2
Steps To Reproduce
Provide a detailed list of steps that reproduce the issue.
- Use
babel-plugin-module-resolver@4.0.0
with short imports in project, use react-native@0.63+ - Assemble release iOS build in xcode
Expected Results
Release iOS build assembled succesfully.
Already raised issues:
For the babel plugin we already have this issue: https://github.com/tleunen/babel-plugin-module-resolver/issues/403 But the reason in react-native codebase changes, because 0.62 version works fine.
Also we have a PR in react-native repo, that reverts some code for index.ios.js file detection, possibly related to this issue: facebook/react-native#29477
Could you please guys pay attention here, because a lot of production projects use this babel plugin. Thanks
Logs from xcode:
warning: the transform cache was reset.
Welcome to React Native!
Learn once, write anywhere
error src/features/search/container.js: Cannot find module '../shared/queries/search.query.gql'
Require stack:
- /Users/my-project/mobile-web-app/node_modules/babel-plugin-import-graphql/build/index.js
- /Users/my-project/mobile-web-app/node_modules/@react-native-community/cli/node_modules/metro-react-native-babel-transformer/node_modules/@babel/core/lib/config/files/plugins.js
- /Users/my-project/mobile-web-app/node_modules/@react-native-community/cli/node_modules/metro-react-native-babel-transformer/node_modules/@babel/core/lib/config/files/index.js
- /Users/my-project/mobile-web-app/node_modules/@react-native-community/cli/node_modules/metro-react-native-babel-transformer/node_modules/@babel/core/lib/index.js
- /Users/my-project/mobile-web-app/node_modules/@react-native-community/cli/node_modules/metro-react-native-babel-transformer/src/index.js
- /Users/my-project/mobile-web-app/node_modules/metro/src/JSTransformer/worker.js
- /Users/my-project/mobile-web-app/node_modules/metro/src/DeltaBundler/Worker.js
- /Users/my-project/mobile-web-app/node_modules/metro/node_modules/jest-worker/build/workers/processChild.js. Run CLI with --verbose flag for more details.
+ echo 'React Native, please report it here: https://github.com/facebook/react-native/issues'
React Native, please report it here: https://github.com/facebook/react-native/issues
+ exit 2
File ../shared/queries/search.query.gql
can’t be resolved, it is defined as relative path with babel plugin:
import searchQuery from "core/shared/queries/search.query.gql"
Issue Analytics
- State:
- Created 3 years ago
- Comments:8
For the meantime, I found this https://github.com/facebook/react-native/issues/29351#issuecomment-657929014
@riadhriadh Yes, I can confirm, this PR fixes the issue: https://github.com/facebook/react-native/pull/29477
I have assembled release iOS build locally with this change and it works! We need to ask maintainers to merge this PR… But there is no activity on it now…