Skip to content
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

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

Closed
7 tasks done
sznowicki opened this issue Sep 15, 2022 · 5 comments
Closed
7 tasks done

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

sznowicki opened this issue Sep 15, 2022 · 5 comments
Labels
bug: upstream Bug in a dependency of Vite

Comments

@sznowicki
Copy link

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

@sapphi-red sapphi-red added the bug: upstream Bug in a dependency of Vite label Sep 18, 2022
@sapphi-red
Copy link
Member

If this function is taking much time, I think there isn't anything Vite could do because this function is in rollup.
#10121 (comment)
https://github.com/rollup/rollup/blob/27c0557f904321d649c9bd85f6fb670ca5700427/src/Graph.ts#L165

Would you create an issue in rollup?

@sznowicki
Copy link
Author

Sure, thx for pointing to a right direction

@sapphi-red
Copy link
Member

Closing as it was fixed in rollup 2.79.1

@sznowicki
Copy link
Author

@sapphi-red can you share some info when it should land in Vite?

@sapphi-red
Copy link
Member

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.

@github-actions github-actions bot locked and limited conversation to collaborators Oct 15, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug: upstream Bug in a dependency of Vite
Projects
None yet
Development

No branches or pull requests

2 participants