Skip to content

babel-plugin-module-resolver doesn't work with react-native 0.63.0+ for iOS production builds #29636

Description

@oleksandr-dziuban

Description

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.

  1. Use babel-plugin-module-resolver@4.0.0 with short imports in project, use react-native@0.63+
  2. 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: tleunen/babel-plugin-module-resolver#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:
#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"

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions