Skip to content

fix(extensions): drop shiki from the extensions barrel#369

Merged
jaysin586 merged 1 commit into
mainfrom
fix/shiki-out-of-extensions-barrel
Jul 14, 2026
Merged

fix(extensions): drop shiki from the extensions barrel#369
jaysin586 merged 1 commit into
mainfrom
fix/shiki-out-of-extensions-barrel

Conversation

@jaysin586

Copy link
Copy Markdown
Contributor

Summary

v1.8.0 (#361) re-exported the shiki extension from the /extensions barrel, which hard-breaks every consumer who imports anything from the barrel without shiki installed — Vite fails with Could not resolve "shiki/core" imported by "@humanspeak/svelte-markdown" even though shiki is an optional peer dependency and the consumer never opted into highlighting. The root cause: createShikiHighlighter.ts statically imports shiki/core from plain JS, so bundlers eagerly resolve it as part of the barrel's module graph (unlike KaTeX, whose static import lives inside a .svelte file and only resolves once the renderer is actually used).

This restores the shiki spike's original, documented invariant — shiki ships only via the dedicated @humanspeak/svelte-markdown/extensions/shiki subpath and is deliberately not re-exported from the barrel — and adds two regression guards so it cannot silently ship again. CI missed the original regression because tree-shaking.mjs only verified final-bundle contents via subpath imports; the failure mode is dev-time module resolution of the barrel.

Note for shiki users on v1.8.0–v1.8.3: change your import from .../extensions to .../extensions/shiki — a one-line change. All other barrel exports are untouched.

Changes

  • 🐛 src/lib/extensions/index.ts — remove all shiki re-exports from the barrel; doc comment records the invariant and points to the subpath
  • 🧪 src/lib/extensions/barrel-optional-deps.test.ts (new) — walks the barrel's transitive plain-TS module graph and fails on any shiki import
  • 🧪 scripts/tree-shaking.mjs — new "extensions barrel stays shiki-free" scenario (all 10 scenarios pass)
  • 📚 src/lib/extensions/shiki/index.ts — replace the stale SPIKE header with the shipped-via-subpath-only invariant
  • 📚 Docs demos (ComponentRendered/FallbackRendered), the syntax-highlighting page, and the README example now import from /extensions/shiki

Verification

  • 973/973 unit tests pass (148 files, including the new guard)
  • pnpm package + publint clean; built dist/extensions/index.js contains no shiki imports
  • pnpm test:tree-shaking — 10/10 scenarios pass
  • pnpm check — 0 errors; trunk check — no issues

Commits

  • d20b6a5 fix(extensions): drop shiki from the extensions barrel

🤖 Generated with Claude Code

Shiki's implementation statically imports shiki/core from plain JS, so
re-exporting it from the /extensions barrel (shipped in v1.8.0, #361)
forced every barrel consumer's bundler to resolve the optional shiki
peer dependency — hard-breaking consumers without shiki installed even
when they never use highlighting. This restores the shiki spike's
documented invariant: shiki ships only via the dedicated
extensions/shiki subpath.

Guards so it cannot silently regress again:
- barrel-optional-deps.test.ts walks the barrel's transitive plain-TS
  module graph and fails on any shiki import
- tree-shaking.mjs gains an 'extensions barrel stays shiki-free' case

Docs demos, the syntax-highlighting page, and the README example now
import from @humanspeak/svelte-markdown/extensions/shiki.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@jaysin586 jaysin586 added bug Apply to any code that fixes incorrect behavior or errors documentation Improvements or additions to documentation breaking-change Apply to changes that break backward compatibility javascript Pull requests that update javascript code labels Jul 14, 2026
@jaysin586 jaysin586 self-assigned this Jul 14, 2026
@jaysin586 jaysin586 merged commit dfc1bb2 into main Jul 14, 2026
5 checks passed
@jaysin586 jaysin586 deployed to production July 14, 2026 18:47 — with GitHub Actions Active
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaking-change Apply to changes that break backward compatibility bug Apply to any code that fixes incorrect behavior or errors documentation Improvements or additions to documentation javascript Pull requests that update javascript code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant