Skip to content

Lazy-load TerminalView to shrink the initial client bundle - #7

Merged
nananek merged 1 commit into
masterfrom
optimize-client-bundle-splitting
Jul 29, 2026
Merged

Lazy-load TerminalView to shrink the initial client bundle#7
nananek merged 1 commit into
masterfrom
optimize-client-bundle-splitting

Conversation

@nananek

@nananek nananek commented Jul 29, 2026

Copy link
Copy Markdown
Owner

Summary

  • @xterm/xterm (+ its addons) is only used by TerminalView, but it was statically imported and mounted eagerly (display:none) even before any terminal tab was opened.
  • Switched to React.lazy + Suspense so the xterm-heavy chunk only loads when a user actually opens a terminal tab.

Results

Before After
Initial JS 577.45 kB (gzip 158.62 kB) 224.54 kB (gzip 70.13 kB)
Terminal chunk (bundled in) 354.23 kB (gzip 89.63 kB), loaded on first terminal open

Clears Vite's "chunk larger than 500 kB" build warning.

Test plan

  • npm run build --workspace=client — no more chunk-size warning, confirmed the TerminalView-*.js/.css chunk is split out
  • Served the production dist/ via vite preview and confirmed index.html/main chunk only reference the main bundle, and the TerminalView chunk path is referenced via dynamic import inside it, and both chunks are served with 200
  • Manual in-browser check (open a terminal tab, verify it still renders/functions) not performed — no Chrome extension connected in this session

🤖 Generated with Claude Code

https://claude.ai/code/session_01Ea4cGkRx67MmcaM2cAZ3CQ

@xterm/xterm and its addons only used by TerminalView, but it was
statically imported and rendered eagerly (just display:none) even
when no terminal tab was open. Code-splitting it behind React.lazy
drops the initial JS payload from 577 kB to 225 kB (gzip 159→70 kB),
clearing Vite's 500 kB chunk-size warning; the terminal chunk now
loads on demand when a tab is actually opened.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Ea4cGkRx67MmcaM2cAZ3CQ
@nananek
nananek merged commit 72426cd into master Jul 29, 2026
2 checks passed
@nananek
nananek deleted the optimize-client-bundle-splitting branch July 29, 2026 10:03
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