fix(extensions): drop shiki from the extensions barrel#369
Merged
Conversation
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>
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
v1.8.0 (#361) re-exported the shiki extension from the
/extensionsbarrel, which hard-breaks every consumer who imports anything from the barrel withoutshikiinstalled — Vite fails withCould not resolve "shiki/core" imported by "@humanspeak/svelte-markdown"even thoughshikiis an optional peer dependency and the consumer never opted into highlighting. The root cause:createShikiHighlighter.tsstatically importsshiki/corefrom plain JS, so bundlers eagerly resolve it as part of the barrel's module graph (unlike KaTeX, whose static import lives inside a.sveltefile 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/shikisubpath 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 becausetree-shaking.mjsonly verified final-bundle contents via subpath imports; the failure mode is dev-time module resolution of the barrel.Changes
src/lib/extensions/index.ts— remove all shiki re-exports from the barrel; doc comment records the invariant and points to the subpathsrc/lib/extensions/barrel-optional-deps.test.ts(new) — walks the barrel's transitive plain-TS module graph and fails on anyshikiimportscripts/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 invariantComponentRendered/FallbackRendered), the syntax-highlighting page, and the README example now import from/extensions/shikiVerification
pnpm package+ publint clean; builtdist/extensions/index.jscontains no shiki importspnpm test:tree-shaking— 10/10 scenarios passpnpm check— 0 errors;trunk check— no issuesCommits
d20b6a5fix(extensions): drop shiki from the extensions barrel🤖 Generated with Claude Code