Skip to content

Terrible slow builds when more than 1000 files in a module #4642

@sznowicki

Description

@sznowicki

Full explanation and background in original, ViteJS issue.

Long story short, when there is a bigger bundle, in my case, a design system monorepo that contains ~2600 icons (each as a React component, referenced in an index file that Maps them as ['name', () => import('../component/name')], rollup build takes in my case 46 minutes (while ParcelJS is much faster, ~30 seconds).

I tried to debug it and it seems like rollup graphs dependencies in a way that it creates loop iteration for each file and within that iteration it iterates over every files in a bundle, which seems to me like O(n^2) performance.

I've made a repro repo to demo the problem. You can compare there ViteJS that uses Rollup and Parceljs (that uses custom bundler I believe).

Also for reference, my findings in a ViteJS discussion thread.

private async generateModuleGraph(): Promise<void> {

I believe this is worth looking, even though it's not that common problem because not many people have this big marketing iconography in their repos ;)

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions