Skip to content

Group world data into per-category chunks, and add an itch.io build - #103

Merged
thatoneguy10001 merged 2 commits into
masterfrom
chore/itch-build-and-world-chunking
Aug 13, 2026
Merged

Group world data into per-category chunks, and add an itch.io build#103
thatoneguy10001 merged 2 commits into
masterfrom
chore/itch-build-and-world-chunking

Conversation

@thatoneguy10001

Copy link
Copy Markdown
Owner

Cuts the Pages build from 400+ JS chunks to 23, and adds a build target that works on itch.io.

Chunking

engine-wasm.ts globs 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) in manualChunks. The granularity follows how the data is actually consumed:

  • initEngine awaits all six categories for one world in a single Promise.all, so a category is always fetched whole or not at all — finer than category buys nothing.
  • Category rather than whole-world, because listPlayableClasses runs earlier on the character-creation screen. Collapsing a world into one chunk would make class select drag 154 quests with it.
  • world.json is left unmatched deliberately — it is globbed eagerly for the world-select screen, so it belongs in the entry bundle.
Before After
JS chunks 400+ 23
Requests to reach first room ~400 17

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-npcs chunk (563 KB raw / ~186 KB gzipped) trips Vite's 500 KB warning. Expected — initEngine needs every NPC anyway, so splitting it would just restore the requests this removes.

itch.io build

npm run build:itchtsc && 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. Separate outDir so it cannot collide with the Pages build; both gitignored. The Pages deploy is untouched — the workflow still supplies VITE_BASE=/chronos/.

New docs/publishing-itch.md covers build → package → upload.

Roadmap reconciliation

docs/expansion-planning.md was 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 (ActiveLoadoutPayloadSlots, VisitRoomReachRoom, SPD/ACC/CRIT/DODGE→agility/hit/crit_chance/evasion, CraftWeaponAssembledWeapon).

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 FetchItem from E-10.

Verification

  • tsc --noEmit clean; 77 tests pass
  • Built, served and played: world select → Iron & Blood → Vanguard → Gate of Fort Iron, 135/135 HP, items and NPC present
  • Zero console errors, all requests 200

🤖 Generated with Claude Code

thatoneguy10001 and others added 2 commits August 13, 2026 14:00
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>
@thatoneguy10001
thatoneguy10001 merged commit e459da2 into master Aug 13, 2026
10 checks passed
@thatoneguy10001
thatoneguy10001 deleted the chore/itch-build-and-world-chunking branch August 13, 2026 20:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant