Skip to content

Commit

Permalink
feat: migrate to shiki v2
Browse files Browse the repository at this point in the history
  • Loading branch information
antfu committed Jan 20, 2025
1 parent 0a0f95f commit 5e8cd4a
Show file tree
Hide file tree
Showing 6 changed files with 580 additions and 531 deletions.
2 changes: 1 addition & 1 deletion docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"type": "module",
"version": "51.0.1",
"private": true,
"packageManager": "pnpm@9.14.4",
"packageManager": "pnpm@9.15.4",
"scripts": {
"dev": "vitepress",
"build": "vitepress build",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"type": "module",
"version": "51.0.1",
"private": true,
"packageManager": "[email protected].3",
"packageManager": "[email protected].4",
"engines": {
"node": ">=18.0.0"
},
Expand Down
1 change: 1 addition & 0 deletions packages/client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
"@iconify-json/carbon": "catalog:",
"@iconify-json/ph": "catalog:",
"@iconify-json/svg-spinners": "catalog:",
"@shikijs/engine-javascript": "catalog:",
"@shikijs/monaco": "catalog:",
"@shikijs/vitepress-twoslash": "catalog:",
"@slidev/parser": "workspace:*",
Expand Down
3 changes: 2 additions & 1 deletion packages/slidev/node/virtual/shiki.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ export const templateShiki: VirtualModuleTemplate = {
const lines: string[] = []
lines.push(
`import { createHighlighterCore } from "${await resolveImportUrl('shiki/core')}"`,
`import { createJavaScriptRegexEngine } from "${await resolveImportUrl('@shikijs/engine-javascript')}"`,
`export { shikiToMonaco } from "${await resolveImportUrl('@shikijs/monaco')}"`,

`export const languages = ${JSON.stringify(langNames)}`,
Expand All @@ -67,7 +68,7 @@ export const templateShiki: VirtualModuleTemplate = {
'export const shiki = createHighlighterCore({',
` themes: [${themesInit.join(',')}],`,
` langs: [${langsInit.join(',')}],`,
` loadWasm: import('${await resolveImportUrl('shiki/wasm')}'),`,
` engine: createJavaScriptRegexEngine(),`,
'})',

'let highlight',
Expand Down
Loading

0 comments on commit 5e8cd4a

Please sign in to comment.