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

forked from trevato/cs · proposes · 4 behind

The build takes a list of entries and the server serves a bundle per game #15

Merged opened this

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

Merged

`scripts/build.ts` now takes a table of entries — `ENTRIES = [{ name: "app", entry: "src/client/main.ts" }]` — and bundles each to `<name>.<hash>.js`: `bundle()` returns one `{ name, file, code }` per entry and `write(entries, dir)` writes and prints them all. Cleanup is per entry through a shared `isBundleOf(name, file)`: a stale `app.<hex>.js` goes, another game's bundle beside it stays, and any…

shipped production is serving it deploy ae07c2d

opened this

scripts/build.ts now takes a table of entries — ENTRIES = [{ name: "app", entry: "src/client/main.ts" }] — and bundles each to <name>.<hash>.js: bundle() returns one { name, file, code } per entry and write(entries, dir) writes and prints them all. Cleanup is per entry through a shared isBundleOf(name, file): a stale app.<hex>.js goes, another game's bundle beside it stays, and anything in static/ that is not a bundle is left alone. Entry names are validated as plain names before they become part of a file name or a pattern, and two entries sharing a name is an error rather than one silently deleting the other.

src/server.ts resolves a script per entry by exact name (findScripts() → scripts["app"]) instead of the first file matching ^app\.; the static route is otherwise as it was — confined to static/, immutable for a year, the same 404 for a name it does not have. server.ts is 182 lines and still fits in one read, so src/routes.ts was not added; the entry table lives in the build, which the tests already import, rather than in a third place.

Nothing visible changed: / renders the same page with <script type="module" src="/static/app.6864d577a4.js"> — the same hash the current sources produce, so the committed bundle is byte-identical — HEAD / answers 200, every response carries the floor, and GET / measured 0.74 ms min / 1.19 ms median / 2.0 ms max over 40 local requests (bundle 0.97 ms). bun test is 151 passing, up from 145: the freshness test now loops over every entry, scripts/build.test.ts covers the two-entry rebuild trap, the exact-name rules and the name validation, and a server test checks an unknown /static/ bundle name is a 404 with the CSP. No second entry or placeholder page — that is #13; the README says adding one is a line in ENTRIES plus a route.

🤖 Generated with Claude Code

Closes #12

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs