chore: trim Shiki client bundles, patch @pierre/diffs, diffkit theme names - #158
Conversation
- Use createHighlighterCore with explicit @shikijs/langs and JS regex engine for markdown highlighting; drop loadLanguage fallback to full catalog. - Patch @pierre/diffs to avoid bundledLanguages/bundledThemes from shiki; align on shiki 4 via pnpm overrides. - Rename custom markdown themes from vercel-* to diffkit-*.
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
📝 WalkthroughWalkthroughAdded pnpm overrides and a local patch for Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes 🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@packages/ui/src/components/markdown.tsx`:
- Around line 22-34: FENCE_LANG_ALIASES is missing common Shiki fence aliases so
languages like yml, gql, and md fall back to plain text; update the
FENCE_LANG_ALIASES map in components/markdown.tsx (type ShikiBundledLang) to
include at least these mappings: "yml" -> "yaml", "yaml" -> "yaml" (if not
present), "gql" -> "graphql", "graphql" -> "graphql" (if not present), and "md"
-> "markdown" (and "markdown" -> "markdown" if missing) so Shiki receives
canonical language names and highlighting is preserved. Ensure you add only
aliases that map to valid ShikiBundledLang entries used elsewhere in the file.
In `@patches/`@pierre__diffs@1.1.12.patch:
- Around line 14-44: The patch adds dynamic imports like javascript: () =>
import("@shikijs/langs/javascript") and uses `@shikijs/core` but package.json for
`@pierre/diffs`@1.1.12 doesn’t declare `@shikijs/core` or any `@shikijs/langs/`*
packages; update the package manifest to add `@shikijs/core` plus each required
language package (e.g. `@shikijs/langs/javascript`, `@shikijs/langs/typescript`,
`@shikijs/langs/jsx`, `@shikijs/langs/tsx`, `@shikijs/langs/json`,
`@shikijs/langs/html`, `@shikijs/langs/css`, `@shikijs/langs/bash`,
`@shikijs/langs/shellscript`, `@shikijs/langs/python`, `@shikijs/langs/go`,
`@shikijs/langs/rust`, `@shikijs/langs/yaml`, `@shikijs/langs/markdown`,
`@shikijs/langs/diff`, `@shikijs/langs/sql`, `@shikijs/langs/graphql`,
`@shikijs/langs/ruby`, `@shikijs/langs/java`, `@shikijs/langs/c`, `@shikijs/langs/cpp`,
`@shikijs/langs/swift`, `@shikijs/langs/kotlin`, `@shikijs/langs/dockerfile`,
`@shikijs/langs/toml`, `@shikijs/langs/vue`, `@shikijs/langs/svelte`,
`@shikijs/langs/php`, `@shikijs/langs/csharp`, `@shikijs/langs/ini`) with appropriate
versions (or a single compatible range), or alternatively consolidate imports to
only the langs that are truly needed and add those to dependencies; ensure
lockfile is updated and CI passes.
- Around line 12-45: The trimmedBundledLanguages map lacks common aliases so
resolveLanguage falls back to ini for inputs like "js", "ts", "py", "rb", "gql",
"md", "yml", "c++", etc.; update resolveLanguage or trimmedBundledLanguages to
include those aliases (or normalize inputs) so aliases map to the intended keys
(e.g., map "js" -> "javascript", "ts" -> "typescript", "py" -> "python", "rb" ->
"ruby", "gql" -> "graphql", "md" -> "markdown", "yml" -> "yaml", "c++" ->
"cpp"), and ensure resolveLanguage first checks the alias map before falling
back to ini (reference trimmedBundledLanguages and resolveLanguage in the diff).
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 7dc071a7-c937-451f-bdf1-d2c7f1449fe0
⛔ Files ignored due to path filters (1)
pnpm-lock.yamlis excluded by!**/pnpm-lock.yaml
📒 Files selected for processing (7)
package.jsonpackages/ui/package.jsonpackages/ui/src/components/markdown.tsxpackages/ui/src/lib/diffs-themes.tspackages/ui/src/lib/shiki-bundle.tspackages/ui/src/lib/shiki-themes.tspatches/@pierre__diffs@1.1.12.patch
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
- Patch resolveLanguage: LANG_ALIASES + canonical id before ini fallback; resolved grammar uses canonical name. - Patched @pierre/diffs package.json: declare @shikijs/core, @shikijs/langs, shiki ^4, @shikijs/transformers ^4 (subpaths use the langs package, not per-grammar npm deps). - FENCE_LANG_ALIASES: yml, gql, md (yaml/graphql/markdown already canonical).
Uh oh!
There was an error while loading. Please reload this page.
Summary
This PR reduces client bundle weight from Shiki and @pierre/diffs by avoiding the default
shikientry (which references every language/theme chunk), and renames custom markdown highlighter themes fromvercel-*todiffkit-*.Changes
createHighlighterCorefromshiki/corewith explicit@shikijs/langsimports, JS regex engine, and customdiffkit-light/diffkit-darkthemes. Unknown fence languages fall back to plaintext.pnpmpatch replacesbundledLanguages/bundledThemesimports, usescreateHighlighterCorefor the shared highlighter, and resolves themes only via registered custom themes. Language loading uses an allowlisted set of@shikijs/langswith a smallinifallback for rare file types.pnpm.overridespin@pierre/diffsto Shiki 4 and matching@shikijs/transformers;patchedDependenciesapplies the patch.Notes
vite buildmay still fail on the SSR step (cloudflare:workers) if that was already an issue locally; unrelated to this PR.Summary by CodeRabbit