-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug?]: React Native monorepo support and yarn 3.1+ #3699
Comments
Did you mean to use https://yarnpkg.com/configuration/manifest#installConfig.hoistingLimits |
Sorry thats a mistake in my bug report, I was indeed using |
Hi! 👋 This issue looks stale, and doesn't feature the Note that we require Sherlock reproductions for long-lived issues (rather than standalone git repositories or similar) because we're a small team. Sherlock gives us the ability to check which bugs are still affecting the master branch at any given point, and decreases the amount of code we need to run on our own machines (thus leading to faster bug resolutions). It helps us help you! 😃 If you absolutely cannot reproduce a bug on Sherlock (for example because it's a Windows-only issue), a maintainer will have to manually add the |
Yarn has always hoisted dependencies of dependencies with |
@larixer I am currently using 3.0.3 and this is not the case, the whole dependency tree for my package with |
@renchap Please provide reproduction |
@renchap The behavior for |
I ran more tests, and it is indeed a bit more complex than what I thought: dependencies of other workspaces are not hoisted when using Here is a repro: https://github.com/renchap/test-yarn In this repo, there are 3 workspaces:
To reproduce:
|
Cool, many thanks for the repro @renchap, I will take a look and come back! |
@renchap Hm, for me, its the opposite, with Yarn 3.1.1, there is no The nested workspace hoisting was changed to fix the bug: |
@larixer Sorry, you are right, its the other way around. I should not post issues just before going to sleep. The issue I am encountering is with the Metro bundler (React Native). As Yarn allows us to dont hoist anything for a workspace it worked fine, but now that those packages are there only through a symlink it no longer works. I tried to dig into Metro's code (which depends on some internal Do you think there could be a new |
@renchap I wonder is there a better way to support symlinks with Metro? I think it will be frustrating one way or another if Metro will not resolve workspace dependencies correctly, I cannot imagine the solution when you just provide some clever hoisting and it magically makes React Native resolve dependencies correctly in all the cases. Do you think you can showcase the problem with Metro somewhere on GitHub, so that I tried to better understand the problem and play with it? |
Sure, here are a few issues:
|
@renchap Yes, I understand, I cannot solve the problem on React Native side, but in a specific example Yarn 3+, React Native project I think it is possible to find the solution how to properly configure Metro, hopefully with some set of plugins. To seek the solution I need something to start with some toy project that showcases the problem. |
Do you want me to prepare a basic repo with a RN workspace showcasing the issue? |
Yep, that would be awesome if you can and have time! |
@renchap Do you think it will solve the problem, if we have something like |
@renchap I'm evaluating different options about React Native monorepo support . I wonder, how Expo seems to be able to support monorepo, as they seems to be React Native-based, did they patch React Native module resolution code? |
Yes, it would at least for me, as I am using a metro plugin to force metro to use the local
I have not used Expo so I dont really know. As a side note, it would be awesome to be able to use Yarn PNP with RN as it currently prevents us to use it entirely (everything in a monorepo, including the RN apps), but this is maybe another topic entirely (as many packages needs to be unplugged for the native code parts to find the files (see react-native-community/cli#27 for example). |
I mean, they declare that they support Yarn workspaces (without any tweaks to hoisting). They seem to do it by purely configuring Metro. I wonder maybe it's possible to utilize their work in a vanilla React Native application by using Expo's Metro config as a base, something like this:
Yes, it would be interesting to make RN work with Yarn PnP, but its worth a separate issue. |
Wait, can you explain that? How come |
@cm-nutrien Check out the official Expo docs for configuring monorepos, they neither use |
Somehow I'd completely missed that, thank you for pointing that out! |
Hi! 👋 This issue looks stale, and doesn't feature the Note that we require Sherlock reproductions for long-lived issues (rather than standalone git repositories or similar) because we're a small team. Sherlock gives us the ability to check which bugs are still affecting the master branch at any given point, and decreases the amount of code we need to run on our own machines (thus leading to faster bug resolutions). It helps us help you! 😃 If you absolutely cannot reproduce a bug on Sherlock (for example because it's a Windows-only issue), a maintainer will have to manually add the |
Sorry for not having posted an update here! |
I have been able to test the monorepo instructions on this page: https://docs.expo.dev/guides/monorepos/
This allowed me to build my React Native app without the need for hoisting and with the latest yarn version 🎉 |
Any approaches for those of us not using expo and are running into issues with yarn 3+? |
You should be able to look at how |
@renchap I wonder if you were able to use the Yarn's PnP feature with your setup? |
@jmarek-sky No, I did not manage to use PnP with React Native, we are still using the |
@renchap could you be so kind as to share the base monorepo you did? :) I am working on the same problem at the moment. |
I recently switched to https://microsoft.github.io/rnx-kit/ and it handles a yarn 3 monorepo (with Mostly due to https://microsoft.github.io/rnx-kit/docs/tools/metro-resolver-symlinks |
I see. Thank you! |
Self-service
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
Additional context
Should this be a feature request for a new
hoistingLimits
value for hoisting the whole dependency tree?The text was updated successfully, but these errors were encountered: