Group world data into per-category chunks, and add an itch.io build - #103
Merged
Conversation
Lazy `import.meta.glob` over world JSON emitted one chunk per file, so a first load fetched 400+ sub-10KB scripts — Iron & Blood alone is 154 quests, 72 NPCs and 71 rooms. Group them by (world, category) instead. That matches how the data is consumed: `initEngine` awaits every category for one world in a single `Promise.all`, so a category is always fetched whole or not at all. Category rather than whole-world granularity because `listPlayableClasses` runs earlier, on character creation — keeping classes separate stops class select from dragging 154 quests down with it. Per-world laziness is unchanged, and `world.json` stays in the entry bundle since it is globbed eagerly for the world-select screen. Build drops from 400+ chunks to 23; a full boot through to the first room goes from ~400 requests to 17. Also add `build:itch` / `preview:itch`. itch.io serves HTML5 games from a randomised subdirectory, so the absolute asset paths the Pages deploy uses 404 there; `--base=./` emits relative ones, into `dist-itch/` so it cannot collide with the Pages build. Reconcile docs/expansion-planning.md against the code. It was written before the sprint that implemented most of it and read as though nothing had shipped, because the implementation renamed nearly everything (`ActiveLoadout`→`PayloadSlots`, `VisitRoom`→`ReachRoom`, SPD/ACC/CRIT/ DODGE→agility/hit/crit_chance/evasion). All 27 items now carry a verified status: 9 of 12 engine and 7 of 7 ungated content items have shipped. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Cuts the Pages build from 400+ JS chunks to 23, and adds a build target that works on itch.io.
Chunking
engine-wasm.tsglobs world JSON lazily, which emits one chunk per file — Iron & Blood alone is 154 quests, 72 NPCs and 71 rooms, so a first load fired ~400 sub-10KB requests.Grouped by
(world, category)inmanualChunks. The granularity follows how the data is actually consumed:initEngineawaits all six categories for one world in a singlePromise.all, so a category is always fetched whole or not at all — finer than category buys nothing.listPlayableClassesruns earlier on the character-creation screen. Collapsing a world into one chunk would make class select drag 154 quests with it.world.jsonis left unmatched deliberately — it is globbed eagerly for the world-select screen, so it belongs in the entry bundle.Per-world laziness verified intact: starting Iron & Blood fetches 7 chunks and zero Millbrook chunks. A world added later gets its own chunks with no config change.
The
world-iron-and-blood-npcschunk (563 KB raw / ~186 KB gzipped) trips Vite's 500 KB warning. Expected —initEngineneeds every NPC anyway, so splitting it would just restore the requests this removes.itch.io build
npm run build:itch→tsc && vite build --base=./ --outDir dist-itch.itch serves HTML5 games from a randomised subdirectory, so the absolute
/chronos/assets/…paths the Pages deploy emits 404 there.--base=./makes them relative. SeparateoutDirso it cannot collide with the Pages build; both gitignored. The Pages deploy is untouched — the workflow still suppliesVITE_BASE=/chronos/.New
docs/publishing-itch.mdcovers build → package → upload.Roadmap reconciliation
docs/expansion-planning.mdwas written 2026-06-18, before the sprint that implemented most of it, and read as though nothing had shipped — because the implementation renamed nearly everything (ActiveLoadout→PayloadSlots,VisitRoom→ReachRoom, SPD/ACC/CRIT/DODGE→agility/hit/crit_chance/evasion,CraftWeapon→AssembledWeapon).All 27 tracked items re-verified against the code and annotated in place. 9 of 12 engine and 7 of 7 ungated content items have shipped. Genuinely outstanding: E-2 (rarity), E-3 (faction standing — a design decision, not work: no faction system exists in engine or world JSON), E-8 (SCAMP, routed around and non-blocking), and
FetchItemfrom E-10.Verification
tsc --noEmitclean; 77 tests pass🤖 Generated with Claude Code