Repository navigation
perf(web): cut the shipped JS bundle by 43% - #2391
Merged
Merged
Conversation
Measured from the built chunks (source-mapped, grouped by package): - react-syntax-highlighter was imported from the package barrel, which also re-exports the highlight.js build (1.3 MB), and oneDark came from the 222 KB prism styles barrel. Both now use deep entries: the lazy markdown chunk drops 1736 KB -> 217 KB. - RuntimeIcon imported each provider's index module to reach its .Color variant; the index also re-exports Mono/Text/Avatar/Combine, so 25 providers shipped 664 KB of SVG. Importing the Color variant directly cuts the main chunk 1723 KB -> 1401 KB. Providers with no colour mark already rendered the fallback glyph, so the three unused index imports are gone. Co-authored-by: Codex <codex@delicious233.com>
Desktop's tsconfig sets types: [], so @types packages only load when a bare import resolves to them. The deep entries replaced that bare import, which dropped the ambient module declarations and broke typecheck for both CodeBlock and prismRegistry. A type-only import restores them without pulling any runtime code (bundle sizes unchanged). Co-authored-by: Codex <codex@delicious233.com>
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configuration
You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
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.
Result
Built web output, measured from source-mapped chunks:
Why
1.
react-syntax-highlighterwas pulled from its package barrel. The barrel also re-exports the highlight.js build, so the lazy code-block chunk carried 1339 KB of highlight.js it never used, plus 959 KB of refractor from the non-light entry.oneDarkcame fromstyles/prism(222 KB, ~200 theme files). CodeBlock now importsdist/esm/prism-lightanddist/esm/styles/prism/one-darkdirectly;prismRegistryalready registers exactly the 14 grammars we render.2.
RuntimeIconimported each provider's index module to reach.Color. Each index re-exports Mono/Text/Avatar/Combine, so 25 providers shipped 189 icon files (664 KB of SVG) into the entry chunk. It now importses/<Provider>/components/Color.js- the same component that was rendered before.OpenAI/Anthropic/Moonshothave no colour mark and already fell back to the local glyph, so their imports are gone.Behaviour is unchanged. The only changed assertion is the OpenAI provider case, which previously asserted the mocked
.Color(a shape that does not exist in production) and now asserts the real fallback glyph.Verification
tscshared / workbench / web / desktop: clean.visual:qa:shell4 shots andvisual:qa:chat16 shots:overflow=false; rendered UI unchanged.Not done (deliberately)
xlsx(488 KB) andmammoth(397 KB) are already dynamic imports behind preview actions. Splitting the remaining 1401 KB entry chunk by route needs a lazy-route change inWorkbenchRoutes- separate and riskier.