chore: switch to shiki-es

This commit is contained in:
Anthony Fu 2022-11-30 13:45:42 +08:00
parent db5a022f3b
commit 04431c7319
4 changed files with 13 additions and 6 deletions

View file

@ -1,4 +1,4 @@
import type { Highlighter, Lang } from 'shiki'
import type { Highlighter, Lang } from 'shiki-es'
export const shiki = ref<Highlighter>()
@ -7,7 +7,7 @@ let shikiImport: Promise<void> | undefined
export function highlightCode(code: string, lang: Lang) {
if (!shikiImport) {
shikiImport = import('shiki')
shikiImport = import('shiki-es')
.then(async (r) => {
r.setCDN('/shiki/')
shiki.value = await r.getHighlighter({

View file

@ -66,6 +66,7 @@
"prettier": "^2.8.0",
"rollup-plugin-node-polyfills": "^0.2.1",
"shiki": "^0.11.1",
"shiki-es": "^0.1.2",
"simple-git-hooks": "^2.8.1",
"std-env": "^3.3.1",
"theme-vitesse": "^0.6.0",

View file

@ -50,6 +50,7 @@ specifiers:
prettier: ^2.8.0
rollup-plugin-node-polyfills: ^0.2.1
shiki: ^0.11.1
shiki-es: ^0.1.2
simple-git-hooks: ^2.8.1
std-env: ^3.3.1
theme-vitesse: ^0.6.0
@ -112,6 +113,7 @@ devDependencies:
prettier: 2.8.0
rollup-plugin-node-polyfills: 0.2.1
shiki: 0.11.1
shiki-es: 0.1.2
simple-git-hooks: 2.8.1
std-env: 3.3.1
theme-vitesse: 0.6.0
@ -7250,11 +7252,15 @@ packages:
engines: {node: '>=8'}
dev: true
/shiki-es/0.1.2:
resolution: {integrity: sha512-eqtfk8idlYlSLAn0gp0Ly2+FbKc2d78IddigHSS4iHAnpXoY2kdRzyFGZOdi6TvemYMnRhZBi1HsSqZc5eNKqg==}
dev: true
/shiki/0.11.1:
resolution: {integrity: sha512-EugY9VASFuDqOexOgXR18ZV+TbFrQHeCpEYaXamO+SZlsnT/2LxuLBX25GGtIrwaEVFXUAbUQ601SWE2rMwWHA==}
dependencies:
jsonc-parser: 3.2.0
vscode-oniguruma: 1.7.0
vscode-oniguruma: 1.6.1
vscode-textmate: 6.0.0
dev: true
@ -8304,8 +8310,8 @@ packages:
vscode-languageserver-protocol: 3.16.0
dev: true
/vscode-oniguruma/1.7.0:
resolution: {integrity: sha512-L9WMGRfrjOhgHSdOYgCt/yRMsXzLDJSL7BPrOZt73gU0iWO4mpqzqQzOz5srxqTvMBaR0XZTSrVWo4j55Rc6cA==}
/vscode-oniguruma/1.6.1:
resolution: {integrity: sha512-vc4WhSIaVpgJ0jJIejjYxPvURJavX6QG41vu0mGhqywMkQqulezEqEQ3cO3gc8GvcOpX6ycmKGqRoROEMBNXTQ==}
dev: true
/vscode-textmate/6.0.0:

View file

@ -2,7 +2,7 @@ import { copy } from 'fs-extra'
const dereference = process.platform === 'win32' ? true : undefined
await copy('node_modules/shiki/', 'public/shiki/', {
await copy('node_modules/shiki-es/dist/assets', 'public/shiki/', {
dereference,
filter: src => src === 'node_modules/shiki/' || src.includes('languages') || src.includes('dist'),
})