Skip to content

Reduce Shiki loading with the JavaScript regex engine - #222

Merged
ruibaby merged 1 commit into
mainfrom
improvement/optimize-shiki-loading
Aug 20, 2026
Merged

Reduce Shiki loading with the JavaScript regex engine#222
ruibaby merged 1 commit into
mainfrom
improvement/optimize-shiki-loading

Conversation

@ruibaby

@ruibaby ruibaby commented Aug 20, 2026

Copy link
Copy Markdown
Member

What changed

  • add a custom Shiki bundle backed by the JavaScript regular expression engine
  • route both the Tiptap code block extension and rendered comment highlighting through the custom bundle
  • bundle only the GitHub Dark theme while keeping built-in languages lazy-loaded
  • add tests for syntax highlighting and the Tiptap extension compatibility surface

Why

The default Shiki bundle uses the WebAssembly-based Oniguruma engine. Opening the comment editor or rendering a comment containing code previously required loading an approximately 232 kB gzip WASM chunk.

The custom bundle removes the Oniguruma dependency and reduces the editor Shiki loading path from approximately 306.8 kB to 95.7 kB gzip.

Validation

  • pnpm -C packages/comment-widget test
  • pnpm exec tsc -p packages/comment-widget/tsconfig.json --noEmit
  • pnpm exec biome check package.json packages/comment-widget/vite.config.ts packages/comment-widget/src/comment-content.ts packages/comment-widget/src/shiki-bundle.ts packages/comment-widget/tests/shiki-bundle.test.ts
  • pnpm build
  • verified that emitted runtime chunks contain neither WebAssembly.instantiate nor the Oniguruma engine

@ruibaby
ruibaby merged commit 2ba4d80 into main Aug 20, 2026
1 check passed
@ruibaby
ruibaby deleted the improvement/optimize-shiki-loading branch August 20, 2026 10:06
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