Vite build is terribly slow when there are more than 1000 files.
See original GitHub issueDescribe 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
- Follow our Code of Conduct
- Read the Contributing Guidelines.
- Read the docs.
- Check that there isn’t already an issue that reports the same bug to avoid creating a duplicate.
- Make sure this is a Vite issue and not a framework-specific issue. For example, if it’s a Vue SFC related bug, it should likely be reported to vuejs/core instead.
- Check that this is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server.
- The provided reproduction is a minimal reproducible example of the bug.
Issue Analytics
- State:
- Created a year ago
- Comments:5 (3 by maintainers)
Closing as it was fixed in rollup 2.79.1
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.