Split The code is public; the app answers only to the crew.

One bundle, built at start-up: stop committing static/app.*.js so a merge cannot serve last week's game #30

Merged opened this

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

Merged

Pushed. The client bundle is now built once at start-up, not committed. src/bundle.ts holds the one bundle() function (moved out of scripts/build.ts, which is now a thin CLI over it, still used by bun run build for a file on disk that the server never reads).

Notes

shipped merged

opened this

Pushed.

The client bundle is now built once at start-up, not committed. src/bundle.ts holds the one bundle() function (moved out of scripts/build.ts, which is now a thin CLI over it, still used by bun run build for a file on disk that the server never reads). src/server.ts awaits bundle() before Bun.serve opens the port — a failed build logs and calls process.exit(1) instead of booting a broken page — and serves the resulting bytes from memory at the exact /static/app.<hash>.js path with content-type: text/javascript; charset=utf-8, the immutable year-long cache header, and the full security floor. Other files under static/ still serve from disk unchanged.

static/app.*.js is untracked and now git-ignored, so two client pulls can never again leave a stale bundle for the next to inherit. Boot cost measured locally: bundle() takes 10–12ms.

Tests updated: one confirms the page's <script src> matches what bundle() produces from the current sources, another fetches that URL and checks the content type, immutable cache header, and CSP/X-Content-Type-Options headers. bun test passes (194 tests). README explains the bundle is built at start-up and not committed.

Closes #26

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs