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.

Page reload on dev server is very slow in large codebase

See original GitHub issue

Describe the bug

In issue https://github.com/vitejs/vite/issues/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 <Suspense> 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

System:
    OS: Linux 5.16 Ubuntu 21.10 21.10 (Impish Indri)
    CPU: (8) x64 11th Gen Intel(R) Core(TM) i7-1165G7 @ 2.80GHz
    Memory: 4.93 GB / 15.32 GB
    Container: Yes
    Shell: 5.1.8 - /bin/bash
  Binaries:
    Node: 14.19.1 - /run/user/1000/fnm_multishells/153575_1649063119273/bin/node
    npm: 8.6.0 - /run/user/1000/fnm_multishells/153575_1649063119273/bin/npm
  Browsers:
    Chrome: 99.0.4844.84
    Firefox: 98.0.2
  npmPackages:
    @vitejs/plugin-react: ^1.3.0 => 1.3.0 
    vite: 2.9.1 => 2.9.1

Used Package Manager

npm

Logs

No response

Validations

Issue Analytics

  • State:open
  • Created a year ago
  • Reactions:33
  • Comments:19 (2 by maintainers)

github_iconTop GitHub Comments

7reactions
jjbell150commented, Apr 4, 2022

+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

2reactions
michalzubkowiczcommented, Nov 19, 2022

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Reload of page after rebuild is very slow - css
I recently went from CSS to SCSS instead. Suddenly afterward my project is very slow for loading the page after a rebuild. (30-50...
Read more >
Slow Django dev server reload
Hi everyone,. I am working on a project which is substantially big (~40k lines of python/django code including management commands). Dev server seems ......
Read more >
Basic Features: Fast Refresh
Next.js' Fast Refresh is a new hot reloading experience that gives you instantaneous feedback on edits made to your React components.
Read more >
Comparing the New Generation of Build Tools
This all takes work, and can slow development servers to a crawl in larger codebases, even after all the work that's gone into...
Read more >
How to Improve TypeScript App Reload Time
One of the causes was a slow startup time — It took approximately 93 seconds to reload my app after saving changes (working...
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