Repository navigation
Replies: 1 comment 1 reply
|
In a large VitePress build the dominant memory consumer is the multi-entry Rollup bundle — every single The numbers below come from a generated 3001-page site (12 MB of markdown) built with vitepress 1.6.4 on Node v24.13.0 / macOS. I also cross-checked Where the memory actually goes (source trace)
Measured numbers (3001 pages,
|
| Config | Result | Peak RSS | Wall time |
|---|---|---|---|
| default (no search) | ✅ | 2.97 GB | 17.1 s |
themeConfig.search.provider:'local' |
✅ | 3.08 GB | 28.9 s |
local search + buildConcurrency: 4 |
✅ | 2.91 GB | 27.6 s |
no search + buildConcurrency: 4 |
✅ | 2.62 GB | 17.5 s |
mpa: true |
✅ | 2.27 GB | 10.8 s |
any config + --max-old-space-size=512 |
❌ OOM in "building client + server bundles" | — | — |
What to do, in order
- Raise the heap.
bin/vitepress.jsis literally:No respawn, no#!/usr/bin/env node import('../dist/node/cli.js')
execArgvhandling —NODE_OPTIONSreaches V8 untouched (proven: setting it to 512 MB makes the build crash at exactly that limit). Your repo already does this (NODE_OPTIONS=--max-old-space-size=8192indocs:build). Note the cap applies to old space; a 3000-page SPA-mode build genuinely needs ~3 GB, so on CI make sure the container has the RAM to back the flag. - Lower
buildConcurrency(top-level site config, default64, present in 2.0-alpha too). Its JSDoc insrc/node/siteConfig.ts: "A lower number will reduce the memory usage but will increase the build time." It caps the SSR render loop and (in 1.x) search indexing:export default defineConfig({ buildConcurrency: 8 })
- Trim or skip the local search index if you use
themeConfig.search.provider: 'local':search.options._render— return''for pages you don't want indexed (documented intypes/default-theme.d.ts: "Return empty string to skip indexing");- or move search off-build entirely (
provider: 'algolia', or none). disableDetailedView/detailedVieware client-UI only — no build-memory effect. AndmaxSuggestionsdoes not exist in VitePress at all (greppedsrc/,types/,docs/).
- Exclude non-site content with
srcExclude(documented; applied indynamicRoutesPlugin.tsglob ignore) — excluded files never become Rollup entries:export default defineConfig({ srcExclude: ['**/README.md', 'blogs/drafts/**'] })
- For very large sites, consider
mpa: true(experimental). It skips the entire multi-entry client bundle (clientResult = config.mpa ? null : await build(...)) — the biggest measured cut (2.97 → 2.27 GB, 1.6× faster), at the cost of SPA hydration/client-side routing. metaChunk: true(experimental) moves the per-page hash-map/site-data blob into a shared chunk — minor, mostly output-size.
What does not help: markdown.cache: false (build always caches), cleanUrls (URL shape only), ignoreDeadLinks (failure, not memory).
One honesty note: your repo currently has ~30 committed .md files, so I couldn't reproduce your exact overflow — the numbers above are from a synthetic 3000-page site. But the crashing phase and the levers are directly verified. Since you're on 2.0.0-alpha.12: buildConcurrency (default 64) and mpa both exist there; one alpha difference is that search indexing in main is a sequential for...of loop rather than pMap.
Uh oh!
There was an error while loading. Please reload this page.
this is my repository
All reactions