perf(web): reduce startup bundle pressure for optional runtimes#746
Merged
Conversation
Add repeatable Web UI bundle-size and main-entry static graph reporters for the staged startup optimization work. The graph reporter supports dependency reachability and direct-import assertions, so future changes can verify that optional runtimes stay out of the startup path without changing Vite warning thresholds.
Route startup tool initialization through narrow Git and LSP entry points so main.tsx no longer imports the full tools barrel. Replace lucide namespace lookups with explicit icon maps while keeping fallback behavior for unknown icons. Defer Mermaid and Prism syntax highlighting to cached async loaders, keeping plain Markdown and code fallback rendering available before optional runtimes load.
b3fd568 to
ba5c8cd
Compare
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
This PR contains the completed stage 0-4 Web UI startup bundle optimization work, squashed into two commits and without the design document.
It keeps
chunkSizeWarningLimitunchanged and focuses on removing accidental startup dependencies rather than hiding the warning.Optimization Plan
scripts/report-web-bundle-size.cjsreports raw and gzip sizes fromdist/assets.scripts/report-web-main-static-graph.cjsreports themain.tsxstatic graph and can assert that optional runtimes stay unreachable from startup.main.tsxnow imports./tools/initializeToolsinstead of the full./toolsbarrel.MermaidServiceonly when Mermaid content needs rendering, validation, or export.Optimization Results
Measured from the stage 0 baseline to the final stage 4 build:
9953.0 KiB raw / 2802.0 KiB gzip->8242.6 KiB raw / 2286.1 KiB gzip.-1710.4 KiB raw / -515.9 KiB gzip.main.tsxstatic graph:1067->1013local modules.14332.4 KiB->13952.4 KiB.3905.1 KiB->3930.0 KiB.mermaidorreact-syntax-highlighter, andmain.tsxno longer imports./toolsdirectly.dist/index.htmldoes not preloadmermaid,prism, orreact-syntaxassets.Experience Protection
SessionSceneor the whole Markdown renderer.Verification
pnpm run lint:webpnpm run type-check:webpnpm --dir src/web-ui run test:runpnpm --dir src/web-ui run buildpnpm run verify:monaco-assetsnode scripts/report-web-bundle-size.cjs --top=20node scripts/report-web-main-static-graph.cjs --assert-external-unreachable=react-syntax-highlighter --assert-external-unreachable=mermaid --assert-no-direct-import=src/web-ui/src/main.tsx:./tools --top=15Select-String -Path dist\index.html -Pattern 'mermaid|prism|react-syntax'git diff --check upstream/main..HEAD