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

forked from trevato/cs · proposes

The engine leaves the repository: scripts/pack.ts writes the package, and the guide's game builds against that copy alone #189

Merged opened this

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

Merged

`scripts/pack.ts` writes the engine out as a package a game could install: `bun run scripts/pack.ts [dir]` (default `dist/engine`, now in `.gitignore`) copies every shipping module under `src/engine/`, `GUIDE.md`, and a generated `package.json` — a name, a `VERSION` constant whose docstring says what it means, `"type": "module"`, `"exports": { ".": "./index.ts" }`, and no dependencies key at all.…

shipped production is serving it deploy ae07c2d

opened this

scripts/pack.ts writes the engine out as a package a game could install: bun run scripts/pack.ts [dir] (default dist/engine, now in .gitignore) copies every shipping module under src/engine/, GUIDE.md, and a generated package.json — a name, a VERSION constant whose docstring says what it means, "type": "module", "exports": { ".": "./index.ts" }, and no dependencies key at all. No .test.ts and no .probe.ts come along. It writes only under the directory it was given, makes it if missing, leaves anything already there alone, and never runs at request time; nothing about FORGE_APP_DATA moved.

scripts/pack.test.ts is the measurement worth reading first. It packs into a mkdtempSync directory of its own and removes it in a finally, then builds example.ts from the copy with Bun.build under a plugin that reads each .ts itself and records the absolute path it read — so the assertion is not "the build succeeded" but "all 21 modules the bundler loaded lie inside the temp directory", which is the only thing that proves no path leads back here. It then imports the packed door from the copy, compares its runtime keys against this repository's door and its re-exported names against SURFACE, and checks the packed clamp is a different function object from ours — a second engine, not a re-export of this one. I verified both failure modes by mutation: dropping renderer.ts from the pack fails three of these tests, and rewriting the sample's import to point back at src/engine/ fails the resolution test alone.

One layout call to look at: example.ts is written flat in the packed directory next to the modules, not in a subdirectory. "Beside the package rather than inside it" is honoured in the sense that matters — it is not one of packed.modules, the door does not offer it, and it reaches the engine only through ./index.ts — because putting it a level up would mean writing outside the directory the script was given, and putting the package in a subdirectory would mean rewriting the sample's import. Both the script's docstring and the new GUIDE.md section say so plainly. GUIDE.md gains "Taking the package out" (no new fenced blocks, so the guide's block rule is untouched), and README lists the script and now says four rules keep the engine a package rather than three. bun test: 841 pass, no bundle byte and no ceiling moved.

🤖 Generated with Claude Code

Closes #117

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs