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.

[Bug?]: React Native monorepo support and yarn 3.1+

See original GitHub issue

Self-service

  • I’d be willing to implement a fix

Describe the bug

Yarn 3.1.0 now hoists dependencies of dependencies when using installConfig.hoistingLimits: "workspaces".

This is a new behaviour compared to 3.0.2

This is breaking some setups, in my case with a React Native app in a monorepo. Metro (React Native bundler) expects all of its dependency tree to be in one unique node_module folder.

From the changelog I understand the previous behaviour might have been unwanted and 3.1.0 “optimized” things, but in practice it breaks setups that relied on it.

To reproduce

As this is a behaviour change and not a bug, I am not sure you need a way to easily reproduce it?

Environment

System:
    OS: macOS 12.0.1
    CPU: (8) x64 Intel(R) Core(TM) i7-6700HQ CPU @ 2.60GHz
  Binaries:
    Node: 16.13.0 - /private/var/folders/1b/wb5vmt3x7kg8gcgt4l11wbjm0000gn/T/xfs-981831cb/node
    Yarn: 3.1.0 - /private/var/folders/1b/wb5vmt3x7kg8gcgt4l11wbjm0000gn/T/xfs-981831cb/yarn
    npm: 8.1.0 - /usr/local/Cellar/node@16/16.13.0/bin/npm

Additional context

Should this be a feature request for a new hoistingLimits value for hoisting the whole dependency tree?

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:33 (12 by maintainers)

github_iconTop GitHub Comments

3reactions
renchapcommented, Feb 3, 2022

I have been able to test the monorepo instructions on this page: https://docs.expo.dev/guides/monorepos/

  • use expo/metro-config
  • updating XCode’s config to look at the correct node_packages folder (in the root of the repo) for the various build commands
  • add export PROJECT_ROOT=$PWD in the “Bundle React Native code and images” build step
  • add --no-jetifier to the android build command (Jetifier should no longer be needed on modern apps)

This allowed me to build my React Native app without the need for hoisting and with the latest yarn version 🎉

1reaction
renchapcommented, Aug 31, 2022

I recently switched to https://microsoft.github.io/rnx-kit/ and it handles a yarn 3 monorepo (with node_modules linker) correctly.

Mostly due to https://microsoft.github.io/rnx-kit/docs/tools/metro-resolver-symlinks

Read more comments on GitHub >

github_iconTop Results From Across the Web

Unable to resolve "react-native" on Monorepo project
I'm trying to insert an Expo application inside a monorepo project, but I get an error with React Native. I used expo-yarn-workspaces and ......
Read more >
Yarn 3.1 Corepack, ESM, pnpm, Optional Packages
With React Native not supporting PnP, and it appears no one is working on it, is there any benefit to upgrading to 3.x...
Read more >
Monorepos in RN | React Native London | February 2022
Callum Hemsley: Running React Everywhere: Monorepos in RNPopularised by tech giants like Google, monorepos have become increasingly popular ...
Read more >
Recently Active 'yarnpkg' Questions - Stack Overflow
I'm working on a project in React and ran into a problem that has me stumped. Whenever I run yarn start I get...
Read more >
@bugsnag/js | Yarn - Package Manager
Bugsnag error monitoring & reporting for JavaScript. Automatically detect JavaScript errors in the browser, Node.js and React Native, with plugins for React ...
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