-
-
Notifications
You must be signed in to change notification settings - Fork 6.3k
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
Page reload on dev server is very slow in large codebase #7608
Comments
+1 I'm having the exact same issue with Vite 2.9.1 on a large React project, startup is instant but loading the page takes 60 seconds to fully load with constant timeouts and refreshes, would be great to have this fixed |
@jjbell150 if you have a good reproduction, please also share it. It would be good that both check with 2.8.6, 2.7.10, and 2.6.13. There were some users reporting regressions in 2.7 for example: #6030 |
2.6.13 - 2.9 So there is no regression between the versions Same app built with webpack (CRA) Difference in first render is quite obvious because of different approach, but reload times are Vite drawbacks |
I'm seeing something very similar porting over a large React codebase. ~40s initial load time(I suspect largely due to tons of SASS) and then ~4.5 page reloads. Perhaps I don't understand how the |
How many modules does your app have? The Vite model doesn't work well when you need to load 1K modules. You can check discussions at #4120. Once the App is loaded, another issue is circular dependencies. They will kill HMR and will trigger a full page reload. It is important to review and avoid them so you hit HMR as much as possible. I think there is space for improvement though, it would be great to somehow get good warnings of circular dependencies and push people in the right direction. And also explore some ways to maybe pre-bundle parts of the App if you don't care about HMR for it at the moment (and lazy loading isn't possible for it). |
@patak-dev , even if you use lazy loading you'll endup with 40-50 components on page, which in my tests will load very slowly especially in Firefox. HMR can be very hard to maintain if there are some more complicates state setups so full reloads are very important. Warnings can be helpful, but conventions should be very clearly documented. At this point none of any apps I've seen are compatible with Vite without hard rewrite. It's not a accusation ;). Wish you all the best and good luck! |
check this article for more details ( in Chinese) https://carljin.com/vite-resolve-request-files-a-ton.html |
This comment was marked as spam.
This comment was marked as spam.
I've noticed this in our storybook project once we switched to vite. |
Still the same issue in Vite v3.1.8 is there any workaround? |
I don't think any workaround is possible. It's design flaw. You should probably split application into smaller parts. |
We have this same problem and are unable to lazy load at this moment. Is there any effort being put towards resolving this design flaw? |
I apologize for the wrong wording here. It's not a flaw, but more a design decision. In Vite every component is treated as a separate file. This approach needs to build applications in such a way, that everything is lazy loaded to not load ALL components on every reload. You cannot just switch from CRA (Create React App) or even plain Webpack to Vite in a large project and expect that everything will work better out of the box. It's wise to choose the right tool for the job, if you cannot do lazy loading probably Vite can be not the best choice, maybe you need some adjustments. |
I have a similar problem, maybe it is the same, maybe not. The truth is that my development compile now takes about 30 minutes to compile, this is something that only happens to me in the team, the rest of my colleagues compile in 2 seconds having the same code base, only they are in Linux with Docker and I am in Windows without docker, and no, it is not because of computer resources, and if it were I do not think the difference would be so brutal. We are working on a somewhat medium-sized project, about 400 components and counting. We are using Tailwind, and I have read that it can cause slow startup, but why only me if we have the same configuration? This is how long it takes my teammates. Does anyone have any suggestions, or at least where to start? |
@mreduar That looks like a WSL2 shell, so I'm going to take a wild guess that your code is stored on your C: drive? If that's the case, then you need to move your code to the WSL2 filesystem, or if that isn't possible downgrade to WSL1: https://stackoverflow.com/a/68974497/2941601 |
No, I don't use WSL2, it's Windows Terminal but with Git Bash. |
@mreduar I've had a similar issue and it turned out there was a big dist (build output) folder inside a source folder. So I think it's worth checking out if there is any unnecessary git-ignored files in your project or simply reclone it, just in case. |
Thank you very much @lessquo! Thank you! Cheers |
In my case i found out a to crossing plugin was the cause for that. |
We have been improving Vite's performance lately and I believe this has been fixed. Closing this as the work has been completed, but if there's more to work on, we'll track it at #12363 instead. Appreciate if anyone following would give Vite 4.3 beta a spin too. |
Describe the bug
In issue
#3208
You've asked to code example, so I've created one:
https://github.com/michalzubkowicz/slow-vite-demo
Problem is that when are many components involved, compilation and reload times are very slow, much more than same app built with Webpack. Example app starts up on my computer more than 10 second (I mean app startup in browser, not a HTTP server startup). Reload times are quite long in comparison to even bigger apps built with Webpack
There is also Firefox bug I've found that make whole thing worse:
https://bugzilla.mozilla.org/show_bug.cgi?id=1125322
It causes that Vite is quite unusable.
In Chrome (or other webkit browser) situation looks better, but still, loading many components (for example 2000) it
I think this problem can be leveraged with proper use of in React, but it needs some work.
Hope this time this report will be helpful
Reproduction
https://github.com/michalzubkowicz/slow-vite-demo
System Info
Used Package Manager
npm
Logs
No response
Validations
The text was updated successfully, but these errors were encountered: