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
Check · Review · Land · Live done — Landed and live in production.
`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
Sign in to join this conversation.
new above
offline
scripts/pack.tswrites the engine out as a package a game could install:bun run scripts/pack.ts [dir](defaultdist/engine, now in.gitignore) copies every shipping module undersrc/engine/,GUIDE.md, and a generatedpackage.json— a name, aVERSIONconstant whose docstring says what it means,"type": "module","exports": { ".": "./index.ts" }, and no dependencies key at all. No.test.tsand no.probe.tscome 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 aboutFORGE_APP_DATAmoved.scripts/pack.test.tsis the measurement worth reading first. It packs into amkdtempSyncdirectory of its own and removes it in afinally, then buildsexample.tsfrom the copy withBun.buildunder a plugin that reads each.tsitself 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 againstSURFACE, and checks the packedclampis a different function object from ours — a second engine, not a re-export of this one. I verified both failure modes by mutation: droppingrenderer.tsfrom the pack fails three of these tests, and rewriting the sample's import to point back atsrc/engine/fails the resolution test alone.One layout call to look at:
example.tsis 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 ofpacked.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.mdgains "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