[GH-ISSUE #5215] GameNarration.tsx is 300 kB of source and now gates the bundle budget #2885

Closed
opened 2026-10-21 05:57:38 +07:00 by bsakaguchi · 3 comments
Owner

Originally created by @kolacheee on GitHub (Aug 17, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/5215

Originally assigned to: @SpicyMarinara on GitHub.

Problem

packages/client/src/components/game/GameNarration.tsx is ~300 kB of source (6,847 lines). It is the single largest component in the client, and it is imported by GameSurface, GameSessionReplay and the storyboard UI.

That size is now load-bearing on the build. The bundle budget in packages/client/vite.config.ts had to be raised from 500 kB to 520 kB in #5209, because:

  • GameSurface measured 499.05 kB on staging before that change — under a kilobyte of headroom. The cap was going to stop whichever feature next touched that area; #5209 happened to be the one.
  • Splitting does not fix it. Giving GameNarration its own manual chunk drops GameSurface to 375 kB but produces a 578 kB narration chunk. Total bytes go slightly down (≈3153 kB → 3111 kB, so it redistributes rather than duplicates), but the largest chunk gets worse. No chunk boundary puts a 300 kB source file under 500 kB.

So the only remaining lever is decomposing the component.

What would help

Pull self-contained pieces out of GameNarration.tsx into siblings — candidates visible from the outside:

  • the logs modal
  • the speaker/avatar resolution and sprite-expression machinery
  • the TTS controls (lib/tts-dialogue.ts and lib/tts-audio-cache.ts are already narration-exclusive)
  • the segment meta row and its nav/interrupt controls
  • the side-remark and party-reaction boxes

Once the file is meaningfully smaller, the manual-chunk split becomes worthwhile on its own merits — it also means editing narration stops invalidating the surface chunk in a returning player's cache — and the budget can go back to 500.

Why not just leave the cap at 520

A budget only does its job while it is tight. 520 buys roughly one more feature in this area before the same conversation happens again, and the next person will hit it without the context above. Worth doing properly rather than ratcheting.

Notes

Measurements taken on feat/5209-collapsible-narration at Engine 2.4.3, via packages/client/scripts/build.mjs.

Originally created by @kolacheee on GitHub (Aug 17, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/5215 Originally assigned to: @SpicyMarinara on GitHub. ## Problem `packages/client/src/components/game/GameNarration.tsx` is **~300 kB of source (6,847 lines)**. It is the single largest component in the client, and it is imported by `GameSurface`, `GameSessionReplay` and the storyboard UI. That size is now load-bearing on the build. The bundle budget in `packages/client/vite.config.ts` had to be raised from 500 kB to 520 kB in #5209, because: - `GameSurface` measured **499.05 kB on staging before that change** — under a kilobyte of headroom. The cap was going to stop whichever feature next touched that area; #5209 happened to be the one. - **Splitting does not fix it.** Giving `GameNarration` its own manual chunk drops `GameSurface` to 375 kB but produces a **578 kB** narration chunk. Total bytes go slightly *down* (≈3153 kB → 3111 kB, so it redistributes rather than duplicates), but the largest chunk gets **worse**. No chunk boundary puts a 300 kB source file under 500 kB. So the only remaining lever is decomposing the component. ## What would help Pull self-contained pieces out of `GameNarration.tsx` into siblings — candidates visible from the outside: - the logs modal - the speaker/avatar resolution and sprite-expression machinery - the TTS controls (`lib/tts-dialogue.ts` and `lib/tts-audio-cache.ts` are already narration-exclusive) - the segment meta row and its nav/interrupt controls - the side-remark and party-reaction boxes Once the file is meaningfully smaller, the manual-chunk split becomes worthwhile on its own merits — it also means editing narration stops invalidating the surface chunk in a returning player's cache — and the budget can go back to 500. ## Why not just leave the cap at 520 A budget only does its job while it is tight. 520 buys roughly one more feature in this area before the same conversation happens again, and the next person will hit it without the context above. Worth doing properly rather than ratcheting. ## Notes Measurements taken on `feat/5209-collapsible-narration` at Engine 2.4.3, via `packages/client/scripts/build.mjs`.
bsakaguchi 2026-10-21 05:57:38 +07:00
Author
Owner

@SpicyMarinara commented on GitHub (Aug 18, 2026):

Agreed, needs to be made smaller.

<!-- gh-comment-id:5325271649 --> @SpicyMarinara commented on GitHub (Aug 18, 2026): Agreed, needs to be made smaller.
Author
Owner

@SpicyMarinara commented on GitHub (Aug 18, 2026):

Implementation is in progress in draft PR #5219. The formatter and narration visuals are being separated into focused chunks, and the 500 KiB budget is restored with measured bundle output.

<!-- gh-comment-id:5325555046 --> @SpicyMarinara commented on GitHub (Aug 18, 2026): Implementation is in progress in draft PR #5219. The formatter and narration visuals are being separated into focused chunks, and the 500 KiB budget is restored with measured bundle output.
Author
Owner

@SpicyMarinara commented on GitHub (Aug 18, 2026):

Landed on staging via #5219.

<!-- gh-comment-id:5326375693 --> @SpicyMarinara commented on GitHub (Aug 18, 2026): Landed on staging via #5219.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Pasta-Devs/Marinara-Engine#2885
No description provided.