Replace Comark with marked and trim Shiki bundle in Svelte web app
Session from pi-web on Hugging Face by woxQAQ · MIT · condensed by Coders Talk
The developer wanted to cut bundle size in the pi-web Svelte app, which was bloated because the Comark markdown renderer pulled in full copies of Shiki, KaTeX and mermaid. They aimed to swap it for the lighter marked library and trim unused Shiki languages/themes.
- +0Prompt · +0Comark bundles full shiki, katex and beautiful-mermaid, blowing up our build size.
- +0mAgent did · +0mTraced @comark/svelte's dependency chain, inspected its dist files, ran a build, and confirmed the vendor-mermaid chunk (2.9MB) pulls in full katex and shiki via Comark's bundled components.
- +2mPrompt · +2mComark doesn't give a better experience than marked either. Switch us back to marked.
- +2mAgent did · +2mRewrote MarkdownRenderer.svelte to use marked+DOMPurify instead of @comark/svelte, removed @comark/svelte and katex from package.json, added marked as a dependency, updated the lockfile, and verified with build:web and check:web.
- +8mPrompt · +8mThe web build still bundles a ton of shiki syntax files even though codeHighlight.ts doesn't import them all.
- +8mAgent did · +8mTraced how each Shiki language grammar (markdown, svelte, vue, html) lazily pulls in a chain of embedded languages, confirmed the loader list in codeHighlight.ts was curated (22 langs) but markdown was a heavy embedder; disabled markdown highlighting and mapped md/mdx to plain text, then reran build:web and check:web successfully.
- +14mIntervention · +14mPointed out the agent's fix wasn't enough: the build output still showed a long list of Shiki theme files bundled in.Why: I could still see a pile of theme JS chunks (ayu, catppuccin, dracula, etc.) in web-dist even after the markdown language fix, so the bundle bloat clearly wasn't just about languages.
- +14mAgent did · +14mInvestigated Shiki's createBundledHighlighter/createSingletonShorthands setup and traced it to shiki/dist/themes.mjs, which bundles all built-in themes regardless of the curated language loaders; investigation was still in progress when a diagnostic shell command failed with a syntax error.
- +14mOutcome · +14mComark replaced by marked and markdown Shiki grammar disabled, but the root cause of the theme bloat (full Shiki theme bundle) was identified and left unfixed when the session ended on a failed diagnostic command.
Next time I'd start the first prompt by asking for a full audit of what each bundling layer (parser, languages, themes) actually pulls in, instead of chasing library swaps first. The correction that did the work was calling out that the agent's 'fixed' claim after the markdown-language change was premature — the theme bundle was still huge, and only pushing back got us to the real root cause in shiki's createBundledHighlighter.