question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

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: 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:closed
  • Created 3 years ago
  • Comments:8

github_iconTop GitHub Comments

6reactions
aprilmintacpinedacommented, Sep 4, 2020
3reactions
oleksandr-dziubancommented, Aug 13, 2020

@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…

Read more comments on GitHub >

github_iconTop Results From Across the Web

babel-plugin-module-resolver doesn't work with react native ...
I've been trying to implement module-resolver to my react native app but vs code underlines red the import lines. tsconfig.json file
Read more >
unable to resolve "react-native-svg" - You.com | The search engine ...
React Native / Typescript Error: undefined Unable to resolve module ... bundle starts successfully but when I click on Run on iOS Simulator...
Read more >
React Native Upgrade Helper
It knows which packages* versions are compatible with your specific version of RN, and it uses that knowledge to align dependencies, keeping your...
Read more >
Using TypeScript with React Native
tsx extension (or .ts if the file doesn't contain any JSX). If you tried to run the app now, you'd get an error...
Read more >
React Native for Web Apps - Arionkoder Insights -
This Babel plugin is recommended for the build. Next, we would need to alias our react-native into react-native-web so babel-plugin-module- ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found