server assets: support non-embedded mode for large asset sets
Maintainers usually reply within 2 days
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 48/100
- Issue type
- Feature
- Clarity
- Mostly clear
- Activity status
- Active
- Tech stack
- bun, deno, node.js, rollup, typescript
- Domain
- backend, build-system
Research direction
Start with src/build/virtual/server-assets.ts and the v2 implementation in #4507 to understand the existing asset modes. Compare the filesystem copy and runtime readFile path with the single-module inline option, including how presets without a filesystem retain embedded assets. Done means large asset sets can build without embedding every file on supported presets while the default still works for workers and edge presets.
Written by the indexing model from the issue text.
Description
Tracker for large server asset sets, picked up from #1833 (closed on v2).
In production builds, every file under server/assets becomes its own Rollup module through raw: (src/build/virtual/server-assets.ts). Each file is read into memory as a string and emitted as export default "<content>", and the bundler holds the source, rendered chunk and output of every module until it writes. In #1833, 3,500 JSON files of ~300 KB each (~1 GB) ran out of heap during the build. Building also gets slow from about 1,000 files.
Main embeds assets the same way, so v3 has the same limit. Fixing it needs a mode that doesn't embed every file, for example:
embed: false: copy the files into the server output, bake the metadata at build time, andreadFileat runtime. Only works on presets that have a filesystem (node, bun, deno).embed: "inline": one virtual module for all assets instead of Nraw:chunks. Faster, but still holds everything in memory.
#4507 implemented both as opt-in modes on v2 and is a reasonable starting point. Embedding should stay the default for presets without a filesystem (workers, edge).
The "too many open files" error from the same report was already fixed in #2458.
Opened with AI assistance.
- Dominant language
- TypeScript
- Stars
- 11.5k
- Forks
- 968
- Avg merge
- 4d 9h
- Merged PRs (30d)
- 64
Getting set up
Starts the project's dev container in your browser, under your own GitHub account.
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from nitrojs/nitro
-
pending triage
Difficulty 1/5 Under an hour Newbie friendliness 92/100
Maintainers usually reply within 2 days
-
Difficulty 1/5 Under an hour Newbie friendliness 95/100
Maintainers usually reply within 2 days
-
cloudflare: `nitro deploy` fails when a parent directory has a Wrangler configPossibly taken @draarivpatel-ui claimed this 13 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 73/100
Maintainers usually reply within 2 days
-
documentation
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Maintainers usually reply within 2 days
-
pending triage
Difficulty 5/5 Over a week Newbie friendliness 30/100
nitrojs/nitro#5205 · 1 reaction ·
Maintainers usually reply within 2 days
Similar issues
-
Difficulty 1/5 Under an hour Newbie friendliness 95/100
amosblomqvist/learnharness#1141 ·
Maintainers usually reply within 4 days
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
ranxianglei/billion-context#8319 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
tencent-connect/dsh-qqbot#148 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
JimLiu/open-artifact#126 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100