Repository navigation
fix(worker): stop bundling every docs page twice (#395) - #397
Merged
Merged
Conversation
…ions, use) Phase 1 of the other-locale plan. Adds ja translations of the 19 entry-path pages (index, why, start/*, editions/*, use/*) and the ja sidebar labels for start/ and editions/. Every heading keeps its English id, fences match the English byte for byte, terms follow the glossary's ja column, and each page carries a --stamp. check-translations: ja 0 stale, 79 missing (was 98). Fixes #386 Claude-Session: https://claude.ai/code/session_01QsR2jRsjbApbf83iyTDDXm Co-Authored-By: Claude <noreply@anthropic.com>
Phase 2 of the other-locale plan, first batch: ja for the build/ top level (index, agents, ai-builder, ai-skills, extend-existing-systems, marketplace, packages, reports, templates) and build/data/ (index, relationships, formulas, validation-rules). Same rules as #386: English heading ids, fences byte for byte, glossary ja column, UI labels in English, one line per paragraph, each page stamped. check-translations: ja 0 stale, 66 missing (was 79). Refs #388 Claude-Session: https://claude.ai/code/session_01QsR2jRsjbApbf83iyTDDXm Co-Authored-By: Claude <noreply@anthropic.com>
…388, PR 2 of 7) Adds ja translations for the 11 automation and interface pages: build/automation/{index,flows,workflows,approvals} and build/interface/{index,apps,views,forms,dashboards,pages,actions}. Both sections' meta.ja.json already match the English pages list. Refs #388 Claude-Session: https://claude.ai/code/session_01QsR2jRsjbApbf83iyTDDXm Co-Authored-By: Claude <noreply@anthropic.com>
…tput (#393) /api/search kept every locale's Orama index (30-40 MB each) and every page module page.data.load() imported, so one Worker isolate grew from 58 MB after its first locale to 283 MB after all eight, and #390's ja pages tipped it past 128 MB into 503s. - scripts/gen-search-data.mjs computes each page's structuredData before next build with fumadocs-mdx's own remark chain and writes one gzipped module per locale to apps/docs/.search/; the route reads that instead of importing page modules. - The route keeps the most recently used locale's index only. - check-search-heap.mjs asks the built route in every locale twice and fails above 100 MB or when the second pass keeps growing; it runs in ci.yml after check-search-locales and its --self-test is in SELF_TESTED. Measured on the built route: levels at 50-54 MB across both passes. Fixes #393 Claude-Session: https://claude.ai/code/session_01QsR2jRsjbApbf83iyTDDXm Co-Authored-By: Claude <noreply@anthropic.com>
The tree is unchanged: the diff against main is the #393 commit only. Claude-Session: https://claude.ai/code/session_01QsR2jRsjbApbf83iyTDDXm Co-Authored-By: Claude <noreply@anthropic.com>
The tree is unchanged: the diff against main is the re-landed ja pages only. Claude-Session: https://claude.ai/code/session_01QsR2jRsjbApbf83iyTDDXm Co-Authored-By: Claude <noreply@anthropic.com>
Six route handlers (search, og, sitemap, llms.txt, llms-full.txt, llms.mdx) import lib/source.ts, whose fumadocs-mdx collection holds a lazy import() of every compiled page. Turbopack compiles route handlers as their own module graph, so the Worker carried a second copy of every page module: ~20 MB of upload, and each translated page cost ~170-235 KiB instead of ~86. #388's PR 3 would have gone over the 61,440 KiB budget. - scripts/gen-route-data.mjs (was gen-search-data.mjs) also writes .route-data/collection.ts: .source/server.ts with each page's body import replaced by a read of generated data, and markdown.ts, the English pages' processed Markdown the llms routes serve. With --dev it re-exports the full collection so next dev sees new pages. - lib/source.ts builds its loader on that collection; the page route loads bodies through lib/page-body.ts, the only module that imports the full collection. - lib/packed.ts unpacks the generated gzip+base64 strings. - The Worker budget step prints a per-page projection from the bundle's metafile (check-worker-page-cost.mjs, in SELF_TESTED). Measured, same machine: main f7e4a57 59,173 KiB, this change 38,909 KiB; with every ja page filled in, 43,700 KiB. Fixes #395 Claude-Session: https://claude.ai/code/session_01QsR2jRsjbApbf83iyTDDXm Co-Authored-By: Claude <noreply@anthropic.com>
The tree is unchanged: the diff against main is the #395 commit only. Claude-Session: https://claude.ai/code/session_01QsR2jRsjbApbf83iyTDDXm Co-Authored-By: Claude <noreply@anthropic.com>
Contributor
席位核对 · ACCEPT · 2026-10-29T13:21Z ·
|
zhuangjianguo
marked this pull request as ready for review
October 29, 2026 13:22
zhuangjianguo
added a commit
that referenced
this pull request
Oct 29, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Requested by Steedos · project thread
Fixes #395
Clause-②: no
Metadata-protocol: none
维护者速读
lib/source.ts带着每个页面的懒加载 import。现在 handler 用一个只有 frontmatter 的集合(构建时从 fumadocs-mdx 生成的文件改写),llms 用的英文 Markdown 在构建时生成;页面渲染仍从完整集合加载正文。预算步骤新增每页成本预测。apps/docs/scripts/gen-route-data.mjs的lightCollection(),然后看lib/source.ts和lib/page-body.ts。Worker bundle fits the size budget摘要,新增「Per-page cost」表,每个译文页约 86 KiB,预算还能容纳约 260 页,再加一个完整语言也放得下。What changes
apps/docs/scripts/gen-route-data.mjs(renamed fromgen-search-data.mjs).route-data/collection.ts:.source/server.tswith each page's() => import("…?collection=docs")replaced by() => body("<file>"). It throws unless every page's import was replaced. It also writesmarkdown.ts, the English pages' processed Markdown (remarkLLMsadded at the end of the same remark chain). With--dev,collection.tsre-exports.source/server.tsinstead, sonext devstill sees pages added while it runs. Output moved from.search/to.route-data/.apps/docs/lib/source.ts@/.route-data/collection.getLLMText(page, processed?)takes the Markdown when the caller already has it.apps/docs/lib/page-body.ts(new)loadPageBody(page): the only module that imports the full collection.apps/docs/app/[lang]/docs/[[...slug]]/page.tsxloadPageBody, and passes the loaded_markdowntogetLLMTextfor a translation's Copy Markdown.apps/docs/lib/packed.ts(new)unpack(): the gzip+base64 reader, moved out of the search route so the collection can use it too.apps/docs/app/api/search/route.ts.route-data/and usesunpack(). No behaviour change.apps/docs/package.jsonbuild,type-checkanddev(--dev) rungen-route-data.mjs..github/scripts/check-worker-page-cost.mjs(new)handler.mjs.meta.json. It prints each locale's page-module and search-text KiB per page, what one more translated page costs (the most expensive locale's per-page KiB plus 10 KiB of routing data, calibrated below), how many such pages the budget still holds, and whether one more full locale fits. It fails only when it cannot read the bundle (unreadable,no-pages).--self-testhas 7 cases..github/workflows/ci.ymlWorker bundle fits the size budgetkeeps its verdict (exit "$VERDICT") and prints the projection after it, including when over budget.tools/ci-scripts/run-self-tests.mjscheck-worker-page-cost.mjsadded toSELF_TESTED.The branch carries one
-s oursmerge of the landed #396 branch head so the push fast-forwards. The diff againstmainis only these 11 files.Where the per-page cost went
These numbers come from the esbuild metafile of the packaged handler, with #388's PR 3 applied (61,529 KiB upload):
chunks/ssr/content_docs_*)chunks/content_docs_*)The second copy exists because route handlers are compiled as their own graph, and
.source/server.ts'sdocsLazymap holds animport()of every page. Thatimport()is bundled whether or not a handler callsload(). The handlers only need frontmatter, the page tree, search text and English processed Markdown, so this PR removes the copy. Highlighting and the prerendered HTML/RSC were not the cause: prerendered output is in.open-next/cacheand assets, which do not count toward the upload.Tests
Worker upload (
wrangler deploy --dry-run), all builds on the same machine:f7e4a57(43 ja pages)Headroom with ja fully covered is 61,440 − 43,699 = 17,741 KiB. One more full locale costs about 8,421 KiB by the projection, which leaves about 9,300 KiB after it. Two more would fit too.
The projection, as the step prints it on this PR's build (CI prints the same table; its headroom is 22,523.51 KiB, leaving 14,102 KiB after one more locale):
Calibration: going from 43 to 98 ja pages added 4,791 KiB of upload. Of that, 4,019 KiB was page modules and 238 KiB search text, so the remaining 534 KiB over 55 pages is about 10 KiB each. The projection for those 55 pages is 4,726 KiB, 1.4% under the measured growth.
.html/.rsc/.body/.metafiles under.next/server/appbetween main and this PR, normalizing build id and static chunk names. 9,698 are identical. Everyllms.mdxbody,llms-full.txt,llms.txtandsitemap.xmlis identical. The 61 that differ are of two kinds, and two builds of main differ the same way (43 files on the second main build):record-access,views,webhooks,backuphere;cel,backupbetween the two main builds). With<script>and the colours removed, the HTML of all 9 differing pages is identical to main. It is a token-colour flicker in shiki's light theme, for example a SQL string drawn red instead of blue. It predates this PR.ogshare-card PNGs for ja/zh pages, whose CJK glyphs come from a dynamic font fetch (Failed to load dynamic fontin every build log here).index,build/interface/actions,configure/permissions,cloud/storage-and-limits,deploy/docker,operate/backup,reference/cel,resources/glossary,start/community,editions/compare,use,architecture) in en and ja. Each was loaded with Playwright fromopennextjs-cloudflare preview(workerd) of main and of this PR. The status, article text length and console errors (0) match on all 24. 20 full-page screenshots are byte-identical. The other 4 (operate/backupandreference/cel, in en and ja) differ in one code line's colours, the flicker above.smoke-docs.mjs --basepasses./docs/build/agents.mdx,/llms-full.txt,/llms.txt,/sitemap.xml,/og/docs/ja/build/agents/image.pngand/api/search?locale=jaall answer 200.next dev./ja/docs/build/agents,/docs/build/agents.mdxand/api/searchanswer 200, and.route-data/collection.tsre-exports the full collection.check-search-heap.mjs: level at about 53 MB.check-search-locales.mjs,check-locale-surface.mjs,check-translations.mjs,check-positioning.mjs,check-doc-samples.mjsandgen-zh-hant.mjs --checkpass.pnpm turbo run type-checkandpnpm turbo run test(14 self-tests) pass.Acceptance notes
app/api/search/route.ts: import path andunpack()only. The generator it depends on was renamed, and the unpacking moved tolib/packed.tsso the collection shares it.lib/packed.tsandlib/page-body.ts: new siblings oflib/source.ts.page-body.tshas to be a separate module fromlib/source.ts, because anything the route handlers import must not reference the full collection.apps/docs/package.jsonscripts: to run the renamed generator.reference/celandoperate/backup). Readers see a string drawn red on one deploy and blue on the next.🤖 Generated with Claude Code
https://claude.ai/code/session_01QsR2jRsjbApbf83iyTDDXm