Repository navigation
Worker: upload the docs content and the Shiki grammars as text modules - #25
Merged
Merged
Conversation
The main module bundled to 14.4 MB, which hosts that cap each uploaded part refuse (open-compute: 8 MiB, #24). The generated docs content (4.4 MB) and Shiki's grammars (3.2 MB, inlined by the bundler) now upload as text modules, like the Kumo islands, and are parsed once from JSON. The main module is 6.8 MB; the total upload is unchanged. Refs #24 Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015ALxdbMU5hpZXjGpL2jhC4
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 Can · project thread
Intent: make the Worker's main module small enough for hosts that cap each uploaded part (open-compute: 8 MiB), so Diffinery can deploy there (#24), without changing anything on Cloudflare or celld beyond a lighter cold start.
Opened by Claude Code on behalf of Can (GitHub cnbrkdmrci).
What this changes
The main module bundled to 14.4 MB. Two generated things were most of it: the docs content (
src/docs/content.generated.ts, 4.4 MB of pages, images and downloads as JS literals) and Shiki's grammars (3.2 MB of JS modules that the bundler inlined, though they were meant to load on first use). Both now upload as text modules, the mechanism the Kumo islands already use (*.txt, wrangler's default Text rule, also supported by celld):scripts/build-docs.mjswrites the bulky values tobuild/docs/content.txt(JSON).content.generated.tsimports it andJSON.parses it once, keeping every export's name and type, so no caller changes. Parsing the JSON takes about half the time of parsing the same JS literal (14 ms against 27 ms here).scripts/build-grammars.mjswrites each Shiki grammar the Worker uses tobuild/grammars/<name>.txt(73 grammars for the 62 languages, each once, though JavaScript, CSS and HTML are embedded by many), andsrc/web/grammars.generated.tsimports them.highlight.tstakes its language list from that file and parses a grammar on first use. The language list moved fromhighlight.tsto the build script.Results from
wrangler deploy --dry-run:index.js(main module)content.txt)The source map is still over 8 MiB, so the docs tell open-compute users to set
upload_source_mapstofalse. On Cloudflare nothing changes in what is uploaded or how it behaves.How it was tested
pnpm -r typecheckpasses.apps/diffineryunit tests all pass (1251), including the highlighting tests that compare Diffinery's tokens with Shiki's own modules (highlight.test.ts) and the celld guard. The newmain-module-size.test.tsfails if the generated content goes back into JavaScript. In the fullpnpm -r testrun,containers/runner's PTY sandbox test failed once under load. This change doesn't touch that package, and the test passes when run again.wrangler dev -e dev(workerd): docs pages render with Shiki highlighting, and docs images, the site pages,/install, the CLI bundle, the VS Code extension and the Claude plugin zip are served.Checklist
pnpm -r typecheckandpnpm -r testpassapps/diffinery/docs(self-hosting/architecture.md,self-hosting/configuration.md), plus a CHANGELOG entryapps/diffinery/migrations(none)Refs #24
Generated by Claude Code