feat(serverAssets): opt-in embed modes for large catalogs - #4507
Conversation
Auto-inline ≥50 small text/json files into one virtual module instead of N× raw: Rollup chunks; add embed:false|inline; skip gzip of chunks/raw in fs-tree. Brings multi-thousand JSON serverAssets builds back under ~2s. Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Drop silent auto-inline; default embed:true keeps historical raw: modules. Use createEtag, runParallel error handling, and serverDir-relative paths like public-assets. Tests cover raw / inline / fs modes explicitly. Co-authored-by: Cursor <cursoragent@cursor.com>
Keep default embed:true as historical raw: path; harden embed:false meta via mime; cover runtime/binary/ignore/pattern/mixed modes. Co-authored-by: Cursor <cursoragent@cursor.com>
Drop fsDriver/mime runtime wrappers. Bake meta+relative path at build time; readFile at runtime. Default raw: template unchanged. Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
|
@s00d is attempting to deploy a commit to the Nitro Team on Vercel. A member of the Team first needs to authorize it. |
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
🔗 Linked issue
#1833
❓ Type of change
📚 Description
Large
serverAssetscatalogs (thousands of small JSON files) make Nitro builds slow / OOM because production mode creates one Rollupraw:module per file (#1833). Nuxt 4.x apps that ship translation trees hit this hard.This PR adds an opt-in
embedflag onServerAssetDir. Default staystrue(same historicalraw:behavior — no silent auto-inline).embedtrue/ omittedraw:chunk per file (unchanged)"inline"falseserver/assets/<baseName>; meta+path at build;readFileat runtime (like public-assets node)Also skips per-file gzip in the server size tree for
chunks/raw/**(logging only).Example
Real-world use
nuxt-i18n-micro can register locale JSON trees as
serverAssetsand setembed: 'inline'orembed: falseso Node SSR builds stay fast without dual-writing payloads topublic/.Benchmark (same fixture: 1296 JSON,
compressedSizes: true)chunks/rawraw:raw:raw:embed: "inline"embed: falseNotes:
raw:per file; cost is the same strategy, wall time varies with machine/noise.raw:(same as 2.12.5 / 2.13.4). Speedup requires explicitembed.compressedSizes: false: default ~2270 ms / 625 raw;inline~610 ms / 0;false~1130 ms / 0.Tests
test/unit/server-assets-perf.test.ts— default unchanged, inline/false runtime, binary, ignore, pattern, mixed dirstest/unit/+test/presets/node.test.ts(99 passed, no regressions)📝 Checklist