Public: anyone can read this; the crew can change it.

forked from trevato/cs

The numbers a page boasts are measured, not typed: the bundle sizes on /example are read from the files they describe #207

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

`/example` now reads its own price tag off the files instead of quoting numbers somebody typed: the shooter's bundle had drifted from the page's 71,646 to 93,714 and the example's own from 8,754 to 9,735.

shipped production is serving it deploy ae07c2d

opened this

/example now reads its own price tag off the files instead of quoting numbers somebody typed: the shooter's bundle had drifted from the page's 71,646 to 93,714 and the example's own from 8,754 to 9,735.

scripts/build.ts gains weigh(name, dir) — the committed <name>.<hash>.js read off disk and gzipped at the already-pinned level 9, so a size quoted on a page and a size held to a ceiling are one measurement. src/cost.ts calls it for both bundles and counts the lines of src/engine/example.ts (79) and src/example/main.ts + plan.ts (220, replacing "about two hundred"); src/server.ts runs it once at start-up beside findScripts() and hands the result to examplePage, so nothing reads a file on the request path — /example answers in about 2 ms locally, / and /range are unchanged. src/bytes.ts is the formatter alone: 9,735 where the exact count is the claim, 4.5 kB where the feel of the download is, with the kB stated as 1,024 bytes on the page and in its test. The page's last paragraph now says where its numbers come from, gzip level included.

Worth looking at: src/pages/example.test.ts, which weighs the bundles and counts the sources independently of src/cost.ts, then scans every digit in the cost paragraphs and fails on any that is not a measurement, the gzip level, or the 1,024 in the unit. On main's prose all five of its number assertions are false, which is the drift this fixes. src/server.test.ts checks the same numbers over the wire, and scripts/build.test.ts covers weigh (including the throw for a missing bundle).

Left alone deliberately: src/games.ts's ceilings and its measurement log, the shooter's card (#111), and the README's "What a third game cost" table (#112) — that table still holds the old 8,754 / 4,229. The README gained one bullet describing the two new modules. Try it by opening /example in the preview and comparing the sentence with ls -l static/ plus bun run scripts/build.ts.

🤖 Generated with Claude Code

Closes #128

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs