Lazy-load TerminalView to shrink the initial client bundle - #7
Merged
Conversation
@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
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.
Summary
@xterm/xterm(+ its addons) is only used byTerminalView, but it was statically imported and mounted eagerly (display:none) even before any terminal tab was opened.React.lazy+Suspenseso the xterm-heavy chunk only loads when a user actually opens a terminal tab.Results
Clears Vite's "chunk larger than 500 kB" build warning.
Test plan
npm run build --workspace=client— no more chunk-size warning, confirmed theTerminalView-*.js/.csschunk is split outdist/viavite previewand confirmedindex.html/main chunk only reference the main bundle, and theTerminalViewchunk path is referenced via dynamic import inside it, and both chunks are served with 200🤖 Generated with Claude Code
https://claude.ai/code/session_01Ea4cGkRx67MmcaM2cAZ3CQ