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.

Vite build is terribly slow when there are more than 1000 files.

See original GitHub issue

Describe the bug

As described in a discussion topic I’m trying to move from Parcel to Vite on a Design System project. This project has over 2600 icons, that are small react components. They are included via an export file that is a Map with all those icons as [name: string, importer: async import].

It worked fairly well with Parcel, both dev and build are quick enough to make people not complain.

With Vite dev process is also pretty quick, but build is totally unacceptable. In an original project I let it run and it finished after 46 minutes.

I made a repro repo, there, Parcel finishes in 25 seconds, while Vite is already reaching minutes (it’s 1825 files so I assume it’s going to be around 30 minutes).

My current educated guess is that there’s a problem with how Vite or actually rollup builds the dependency tree. It seems like every single dependency is matched against every other file in the tree. Which make the process run with O(n^2) performance, which with 2600 files makes it all run for over 40 minutes.

For now I have no clue how to debug it further, I might sit on this problem later though.

Reproduction

https://github.com/sznowicki/repro-repo-dynamic-imports

System Info

System:
    OS: macOS 13.0
    CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
    Memory: 307.46 MB / 16.00 GB
    Shell: 5.8.1 - /bin/zsh
  Binaries:
    Node: 16.16.0 - /usr/local/bin/node
    Yarn: 1.22.5 - /usr/local/bin/yarn
    npm: 8.11.0 - /usr/local/bin/npm
  Browsers:
    Chrome: 105.0.5195.102
    Firefox Developer Edition: 99.0
    Safari: 16.1
    Safari Technology Preview: 16.0

Used Package Manager

yarn

Logs

No response

Validations

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
sapphi-redcommented, Sep 22, 2022

Closing as it was fixed in rollup 2.79.1

0reactions
sapphi-redcommented, Sep 30, 2022

I’m not sure but I think it would land in 3.2.

For now, you could use resolutions to override Vite’s rollup dep.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Page reload on dev server is very slow in large codebase #7608
Problem is that when are many components involved, compilation and reload times are very slow, much more than same app built with Webpack....
Read more >
Troubleshooting - Vite
If you are using Linux, file descriptor limits and inotify limits may be causing the issue. As Vite does not bundle most of...
Read more >
Which Generator builds Markdown the fastest?—zachleat.com
Heavier pages aren't exclusively slower for end users—they're slower for developers too. File-based routing of markdown files in both Next.js and Remix is...
Read more >
Laravel Vite Issue - Laracasts
So far, I"m having a hard time understanding why Laravel went to Vite. It's more complicated and bulky than necessary. The only advantage...
Read more >
Building a pomodoro timer with Tauri using React and Vite
When combined with React and Vite, it can be used to build extremely fast binaries for all desktop platforms. Developers can use Tauri...
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