Rollup builds doesn't scale well in large apps. You need to increase Node's memory with --max-old-space-size=4096
to handle all the modules. This is one of Vite's highest-rated issue.
This file documents various findings and attempts to improve this issue.
NOTE: I've only been reading Rollup's source code for a while, so some of these may not be accurate.