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
React Native Project keeps loading infinitely & heats up CPU #1252
Comments
I think I might've used it for a couple of projects but not sure. Since I often jump between |
In my opinion, this should be in the README. I just migrated to pnpm and first thing I discover while trying to run my React Native project is that it doesn't work. |
A while ago someone explained to me that there might be a cultural difference behind this issue: Typical NodeJS developers expect their code to run on any OS, with any package manager, and without installing any other software. Whereas native app developers often must install huge SDKs with multiple prerequisites and special device drivers, for each device that they target. For iOS you even need a specific development machine. In that context, the idea that you must use a certain certain package manager doesn't seem like a big concern. It's just one more "hoop" you have to jump through to make an app. The theory was that this is why there is relatively little effort invested in fixing the React Native symlink handling bugs, whereas other NodeJS packages get fixed quickly. Not sure if it's true. (I haven't used React Native myself beyond trying the demos. But we hear about this issue occasionally from people who are wanting to enable PNPM for their Rush repositories.) |
Are there any updates with this issue? I think they will want to support Yarn Plug'n'Play, so they might make React Native more flexible |
To my knowledge the problem is not in yarn per se or package manager at all. This issue is the root of the problems: facebook/metro#1 I see the following approaches to overcome this limitation:
|
Why not just fix Metro? |
It should, but... but will not be fixed anytime soon, at least in foreseeable future. Start of the storyOriginal issue facebook/metro#1 was created 1252 days or 3 years 5 months 6 days ago. Another pull request jestjs/jest#6993 to fix issue in Jest was provided by @aleclarson 1 year 10 months 15 days ago (and later, 1 year 7 month 7 days ago, was provided updated pull request jestjs/jest#7549 superseding original). It turned out that Jest relies on Watchman (which watches file changes) which also doesn't have symlinks support.
Jest developers refused to merge PR requesting "transparent symlink" implementation (don't know what that means) instead of resolving (cloning content) symlinks.
Watchman also has issue about symlinks support facebook/watchman#105. It was created 3 years 8 months 26 days ago. Watchman developers said in comments that adding symlinks support
Final thoughts
|
So if pnpm would want to support React Native and could solve that problem anyhow by themselves (by hacks / workarounds / etc) - I beg to do that. I think the most straightforward and bulletproof solution would be to add ability to use original npm resolution -
But this is the most simple solution I think. It might be turned on in some config (package.json) only on React Native projects But this will bring in all the benefits of pnpm to React Native world:
|
Eventually on my machine all find . -type d -name node_modules | grep -v node_modules.*node_modules | tr '\n' '\0' | xargs -0 du -sch
30G total we can deal with it. |
What you suggest would require months of development. Just to support a community that doesn't support us. The only solution for this would be to use Yarn's Plug'n'Play. At some point, we will probably support it. And with that, symlinks are not needed. |
@likern You could try using Haul, an alternative to Metro. They claim to support symlinks. I've not tried it myself, as I'm using the PRs that are stalled. Another option, I could generate some git patches from my PRs to both |
Yes, but they do not support Fast Refresh. Which for me is more important feature. |
Might be you could publish your fork of Metro with patches applied? |
@aleclarson do you have the time to generate those patches for |
Does React Native work with Yarn Plug'n'Play? |
It does not, they rely on the node_modules layout so much Yarn v1 had to implement nohoist for it to even work. v2 will have something similar, but better, in the next release yarnpkg/berry#1819 |
I spent a lot of time investigating this issue over the years. Pnpm works fine with React Native. There is a small patch to Métro needed and then you just use a custom module resolver - webpack's 'enhanced-resolve'. There were some small patches in jest waiting to merge last time I checked a couple months ago. When I have some free time I will create a robust example project. |
@vjpr Do you have a snippet of your code to make it work with pnpm ? |
@vjpr it's been 2 months please post something |
Will post tomorrow!
…On Thu 3. Dec 2020 at 16:31, Shivam ***@***.***> wrote:
@vjpr <https://github.com/vjpr> it's been 2 months please post something
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#1252 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AACEWRKCGL7TMPORSG7XKKTSS6VLZANCNFSM4FH7QWIQ>
.
|
@vjpr if you can post that buddy, you will save our lives :) I'm super excited to try out yarn berry or pnpm in order to improve |
Diving back into this now. Want to try and solve it for good because it takes a lot of mental effort to wrap my head around all the pieces each time I return to it. Stay tuned. |
@marudy @ShivamJoker @adelarsq Please see #3010 Working example: https://github.com/vjpr/pnpm-expo-example |
not in CICD we can't. |
For anyone finding this issue through search. The easiest way to make React Native work with pnpm is to use the |
In addition to the I tried to explain most of the issues you probably will run into with monorepos, React Native, and/or Metro. With that context, you should be able to solve it in your preferred way (e.g. rnx-kit, or just adopt the same Metro config properties). There is also this repository that uses Expo, pnpm, and turborepo. |
pnpm version: 2.10.3
Code to reproduce the issue:
https://github.com/deadcoder0904/react-native-darkmode-list
Expected behavior:
Code should run properly
Actual behavior:
Code runs infinitely. I first tried simple
pnpm install
but it raised an error about some babel plugin not installed. So I set.npmrc
file toshamefully-flatten=true
& ranpnpm install
& it went well.Then I typed
pnpm start
& it keeps on running infinitely while heating my CPU. Same thing withyarn
runs in few seconds like 10-15 & withpnpm
I waited 2 minutes until it got very much heated that I closed the running process.Additional information:
node -v
prints: 10.4.1The text was updated successfully, but these errors were encountered: