Skip to content
Docs
Changelog

Docs compile into the Worker, within a budget

The repository's architectural decision, rationale and consequences.

Markdown

Status: accepted · Date: 2026-11-28

Enforcement: apps/web/scripts/assert-docs-budget.mjs in pnpm --filter web build; scripts/measure-worker-build.mjs reports the chunk against the budget for a baseline and the working tree.

The developer docs, the ADRs and the changelog are compiled at build time into one server chunk (docs.page.server-*.js) and served by the same Worker as the app. ADR-0010 measured one change that added 64,903 B gzip of documentation to the Worker and left to the owner whether documentation counts against the Worker budget. On 2026-11-28 the chunk is 4,542,362 B raw and 621,937 B gzip, 15.5% of the 29,293,272 B of server modules, and it is the fastest-growing part of the bundle.

Decision

  1. Docs keep compiling into the Worker. /docs, /llms.txt, the .md routes, search and the changelog stay one deployment with the app, and a change to behaviour ships with its page in the same commit.
  2. The docs chunk has its own budget, separate from the code budgets of ADR-0010: 5,500,000 B raw, about a fifth above today's size. The budget is the constant DOCS_CHUNK_BUDGET_BYTES in scripts/docs-chunk.mjs.
  3. The web build fails when the chunk is over the budget and prints its size and share of the budget on every build. scripts/measure-worker-build.mjs records the chunk for the baseline and for the working tree, so a pull request can state the delta.
  4. Raising the budget is a one-line change in the pull request that needs it, with the measured size in the Before / After table. Docs that describe behaviour are worth their bytes; the budget exists so that growth is a reviewed line and not a side effect.

Consequences

The Worker's raw size limit is 64 MiB; at today's 29.3 MB the docs could grow severalfold before the limit matters, so this budget measures growth, not danger. The first response to the bundle trigger of ADR-0020 (raw bundle over 40 MiB or startup over 400 ms) is to stop compiling docs into the Worker, which would supersede this record. The chunk is found by its file name; renaming docs.page.server.ts fails the check until scripts/docs-chunk.mjs follows.

Alternatives

  • Serve docs from a static site or a second Worker. Two deployments can drift, and the docs tests could no longer check links against the routes of the same build.
  • No budget. ADR-0010 showed that documentation growth hides inside a code measurement.
  • A gzip budget. The platform limit is on uncompressed bytes, and raw bytes do not depend on the compression level; gzip is reported next to it.
Edit on GitHubDocumentation is in English.
Cookie settings
We use essential cookies to make our app work. With your consent, we also use optional cookies to improve your experience.

Read our Cookie Policy and Privacy Policy.