Skip to content

Commit 0c5a51a

Browse files
authoredSep 29, 2024··
feat(perf): skip bundling for assets (#795)
1 parent c8accc9 commit 0c5a51a

27 files changed

+733
-752
lines changed
 

‎.gitignore

+5-3
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,11 @@ logs
1111
node_modules
1212
temp
1313
tmp
14-
packages/shiki/src/assets/langs
15-
packages/shiki/src/assets/themes
16-
packages/shiki/src/assets/*.json
14+
packages/shiki/src/langs
15+
packages/shiki/src/themes
16+
packages/shiki/src/*.json
17+
packages/shiki/src/langs
18+
packages/shiki/src/themes
1719
cache
1820
.eslintcache
1921
report-engine-js-compat.json

‎eslint.config.js

+6-1
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,17 @@ export default antfu(
2222
},
2323
},
2424
ignores: [
25-
'packages/shiki/src/assets/*.ts',
2625
'**/fixtures/**',
2726
'**/vendor/**',
2827
'**/test/out/**',
2928
'docs/languages.md',
3029
'docs/themes.md',
30+
// Generated Files
31+
'packages/shiki/src/langs/**',
32+
'packages/shiki/src/themes/**',
33+
'packages/shiki/src/langs-bundle-full.ts',
34+
'packages/shiki/src/langs-bundle-web.ts',
35+
'packages/shiki/src/themes.ts',
3136
],
3237
},
3338
{

‎packages/engine-javascript/test/compare.test.ts

+16-16
Original file line numberDiff line numberDiff line change
@@ -46,51 +46,51 @@ export interface Cases {
4646
const cases: Cases[] = [
4747
{
4848
name: 'json-basic',
49-
theme: () => import('../../shiki/src/assets/themes/nord'),
50-
lang: () => import('../../shiki/src/assets/langs/json'),
49+
theme: () => import('../../shiki/src/themes/nord.mjs'),
50+
lang: () => import('../../shiki/src/langs/json.mjs'),
5151
cases: [
5252
'{"foo":{"bar":1}}',
5353
'[undefined, null, true, false, 0, 1, 1.1, "foo", [], {}]',
5454
],
5555
},
5656
{
5757
name: 'html-basic',
58-
theme: () => import('../../shiki/src/assets/themes/nord'),
59-
lang: () => import('../../shiki/src/assets/langs/html'),
58+
theme: () => import('../../shiki/src/themes/nord.mjs'),
59+
lang: () => import('../../shiki/src/langs/html.mjs'),
6060
cases: [
6161
'<div class="foo">bar</div>',
6262
'<!DOCTYPE html><html><head><title>foo</title></head><body>bar</body></html>',
6363
],
6464
},
6565
{
6666
name: 'ts-basic',
67-
theme: () => import('../../shiki/src/assets/themes/nord'),
68-
lang: () => import('../../shiki/src/assets/langs/typescript'),
67+
theme: () => import('../../shiki/src/themes/nord.mjs'),
68+
lang: () => import('../../shiki/src/langs/typescript.mjs'),
6969
cases: [
7070
'const foo: string = "bar"',
7171
],
7272
},
7373
{
7474
name: 'jsonc',
75-
theme: () => import('../../shiki/src/assets/themes/nord'),
76-
lang: () => import('../../shiki/src/assets/langs/jsonc'),
75+
theme: () => import('../../shiki/src/themes/nord.mjs'),
76+
lang: () => import('../../shiki/src/langs/jsonc.mjs'),
7777
cases: [
7878
'// comment\n{"foo":"bar"}',
7979
],
8080
},
8181
{
8282
name: 'vue',
83-
theme: () => import('../../shiki/src/assets/themes/vitesse-dark'),
84-
lang: () => import('../../shiki/src/assets/langs/vue'),
83+
theme: () => import('../../shiki/src/themes/vitesse-dark.mjs'),
84+
lang: () => import('../../shiki/src/langs/vue.mjs'),
8585
cases: [
8686
`<script setup>\nimport { ref } from 'vue'\n</script>`,
8787
`<template>\n<div>{{ foo }}</div>\n</template>`,
8888
],
8989
},
9090
{
9191
name: 'toml',
92-
theme: () => import('../../shiki/src/assets/themes/nord'),
93-
lang: () => import('../../shiki/src/assets/langs/toml'),
92+
theme: () => import('../../shiki/src/themes/nord.mjs'),
93+
lang: () => import('../../shiki/src/langs/toml.mjs'),
9494
cases: [
9595
[
9696
`# This is a TOML document`,
@@ -104,8 +104,8 @@ const cases: Cases[] = [
104104
},
105105
{
106106
name: 'sql',
107-
theme: () => import('../../shiki/src/assets/themes/nord'),
108-
lang: () => import('../../shiki/src/assets/langs/sql'),
107+
theme: () => import('../../shiki/src/themes/nord.mjs'),
108+
lang: () => import('../../shiki/src/langs/sql.mjs'),
109109
cases: [
110110
'SELECT * FROM foo',
111111
[
@@ -119,8 +119,8 @@ const cases: Cases[] = [
119119
{
120120
skip: true,
121121
name: 'markdown',
122-
theme: () => import('../../shiki/src/assets/themes/nord'),
123-
lang: () => import('../../shiki/src/assets/langs/markdown'),
122+
theme: () => import('../../shiki/src/themes/nord.mjs'),
123+
lang: () => import('../../shiki/src/langs/markdown.mjs'),
124124
cases: [
125125
[
126126
'# Header',

‎packages/shiki/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@
129129
"@types/hast": "catalog:"
130130
},
131131
"devDependencies": {
132+
"rollup-plugin-copy": "^3.5.0",
132133
"tm-grammars": "catalog:",
133134
"tm-themes": "catalog:",
134135
"vscode-oniguruma": "catalog:"

‎packages/shiki/rollup.config.mjs

+8-14
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ const external = [
3535
'@shikijs/engine-oniguruma',
3636
'@shikijs/vscode-textmate',
3737
'shiki/wasm',
38+
/[/\\]src[/\\](langs|themes)[/\\]/g,
3839
]
3940

4041
const plugins = [
@@ -52,27 +53,20 @@ export default defineConfig([
5253
{
5354
input: [
5455
...entries,
55-
// add language files entries
56-
...fg.sync('src/assets/langs/*.js'),
5756
],
5857
output: {
5958
dir: 'dist',
6059
format: 'esm',
61-
entryFileNames: (f) => {
62-
if (f.facadeModuleId?.match(/[\\/]langs[\\/]/))
63-
return `langs/${f.name}.mjs`
64-
return '[name].mjs'
65-
},
66-
chunkFileNames: (f) => {
67-
if (f.moduleIds.some(i => i.match(/[\\/]langs[\\/]/)))
68-
return `langs/${f.name}.mjs`
69-
else if (f.moduleIds.some(i => i.match(/[\\/]themes[\\/]/)))
70-
return 'themes/[name].mjs'
71-
return 'chunks/[name].mjs'
72-
},
60+
entryFileNames: '[name].mjs',
7361
},
7462
plugins: [
7563
...plugins,
64+
copy({
65+
targets: [
66+
{ src: './src/langs', dest: 'dist' },
67+
{ src: './src/themes', dest: 'dist' },
68+
],
69+
}),
7670
],
7771
external,
7872
},

‎packages/shiki/scripts/prepare.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ import fs from 'fs-extra'
22
import { prepareLangs } from './prepare/langs'
33
import { prepareTheme } from './prepare/themes'
44

5-
await fs.ensureDir('./src/assets/langs')
6-
await fs.emptyDir('./src/assets/langs')
7-
await fs.ensureDir('./src/assets/themes')
8-
await fs.emptyDir('./src/assets/themes')
5+
await fs.ensureDir('./src/langs')
6+
await fs.emptyDir('./src/langs')
7+
await fs.ensureDir('./src/themes')
8+
await fs.emptyDir('./src/themes')
99
await prepareLangs()
1010
await prepareTheme()

‎packages/shiki/scripts/prepare/langs.ts

+10-13
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,8 @@ export async function prepareLangs() {
9696
console.log(json.name, json.embeddedLangs)
9797

9898
await fs.writeFile(
99-
`./src/assets/langs/${lang.name}.js`,
100-
`${COMMENT_HEAD}
101-
${deps.map(i => `import ${i.replace(/\W/g, '_')} from './${i}'`).join('\n')}
99+
`./src/langs/${lang.name}.mjs`,
100+
`${deps.map(i => `import ${i.replace(/\W/g, '_')} from './${i}.mjs'`).join('\n')}
102101
103102
const lang = Object.freeze(JSON.parse(${JSON.stringify(JSON.stringify(json))}))
104103
@@ -108,18 +107,17 @@ ${[
108107
' lang',
109108
].join(',\n') || ''}
110109
]
111-
`.replace(/\n{2,}/g, '\n\n'),
110+
`.replace(/\n{2,}/g, '\n\n').trimStart(),
112111
'utf-8',
113112
)
114113

115114
for (const alias of json.aliases || []) {
116115
if (isInvalidFilename(alias))
117116
continue
118117
await fs.writeFile(
119-
`./src/assets/langs/${alias}.js`,
120-
`${COMMENT_HEAD}
121-
// ${alias} is an alias of ${lang.name}
122-
export { default } from './${lang.name}'
118+
`./src/langs/${alias}.mjs`,
119+
`/* Alias ${alias} for ${lang.name} */
120+
export { default } from './${lang.name}.mjs'
123121
`,
124122
'utf-8',
125123
)
@@ -129,9 +127,8 @@ export { default } from './${lang.name}'
129127
if (isInvalidFilename(name))
130128
continue
131129
await fs.writeFile(
132-
`./src/assets/langs/${name}.d.ts`,
133-
`${COMMENT_HEAD}
134-
import type { LanguageRegistration } from '@shikijs/core'
130+
`./src/langs/${name}.d.mts`,
131+
`import type { LanguageRegistration } from '@shikijs/core'
135132
const langs: LanguageRegistration []
136133
export default langs
137134
`,
@@ -169,14 +166,14 @@ export default langs
169166
id: i.name,
170167
name: i.displayName || i.name,
171168
aliases: i.aliases,
172-
import: `__(() => import('./langs/${i.name}')) as DynamicImportLanguageRegistration__`,
169+
import: `__(() => import('./langs/${i.name}.mjs')) as DynamicImportLanguageRegistration__`,
173170
}) as const)
174171
.sort((a, b) => a.id.localeCompare(b.id))
175172

176173
const type = info.flatMap(i => [...i.aliases || [], i.id]).sort().map(i => ` | '${i}'`).join('\n')
177174

178175
await fs.writeFile(
179-
`src/assets/${fileName}.ts`,
176+
`src/${fileName}.ts`,
180177
`${COMMENT_HEAD}
181178
import type { DynamicImportLanguageRegistration, BundledLanguageInfo } from '@shikijs/core'
182179

‎packages/shiki/scripts/prepare/themes.ts

+6-8
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,16 @@ export async function prepareTheme(): Promise<void> {
88
const theme = await fs.readJSON(`./node_modules/tm-themes/themes/${t.name}.json`)
99

1010
await fs.writeFile(
11-
`./src/assets/themes/${t.name}.js`,
12-
`${COMMENT_HEAD}
11+
`./src/themes/${t.name}.mjs`,
12+
`/* Theme: ${theme.name} */
1313
export default Object.freeze(JSON.parse(${JSON.stringify(JSON.stringify(theme))}))
1414
`,
1515
'utf-8',
1616
)
1717

1818
await fs.writeFile(
19-
`./src/assets/themes/${t.name}.d.ts`,
20-
`${COMMENT_HEAD}
21-
import type { ThemeRegistration } from '@shikijs/core'
22-
19+
`./src/themes/${t.name}.d.mts`,
20+
`import type { ThemeRegistration } from '@shikijs/core'
2321
const theme: ThemeRegistration
2422
export default theme
2523
`,
@@ -30,11 +28,11 @@ export default theme
3028
id: t.name,
3129
displayName: theme.displayName,
3230
type: theme.type,
33-
import: `__(() => import('./themes/${t.name}')) as unknown as DynamicImportThemeRegistration__`,
31+
import: `__(() => import('./themes/${t.name}.mjs')) as unknown as DynamicImportThemeRegistration__`,
3432
}
3533
}))
3634
await fs.writeFile(
37-
'src/assets/themes.ts',
35+
'src/themes.ts',
3836
`${COMMENT_HEAD}
3937
import type { DynamicImportThemeRegistration, BundledThemeInfo } from '@shikijs/core'
4038

‎packages/shiki/src/assets/themes.ts

-366
This file was deleted.

‎packages/shiki/src/bundle-full.ts

+4-6
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,16 @@
11
import type { CreateHighlighterFactory, HighlighterGeneric } from '@shikijs/types'
22
import type {} from 'hast'
3-
import type { BundledLanguage } from './assets/langs-bundle-full'
3+
import type { BundledLanguage } from './langs-bundle-full'
44
import type { BundledTheme } from './themes'
5-
import { bundledLanguages } from './assets/langs-bundle-full'
65
import { createdBundledHighlighter, createSingletonShorthands, warnDeprecated } from './core'
76
import { createOnigurumaEngine } from './engine-oniguruma'
7+
import { bundledLanguages } from './langs-bundle-full'
88
import { bundledThemes } from './themes'
9-
import { getWasmInlined } from './wasm-dynamic'
109

11-
export * from './assets/langs-bundle-full'
1210
export * from './core'
11+
export * from './langs-bundle-full'
1312
export * from './themes'
14-
15-
export { getWasmInlined }
13+
export { getWasmInlined } from './wasm-dynamic'
1614

1715
export type Highlighter = HighlighterGeneric<BundledLanguage, BundledTheme>
1816

‎packages/shiki/src/bundle-web.ts

+4-7
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,16 @@
11
import type { CreateHighlighterFactory, HighlighterGeneric } from '@shikijs/types'
22
import type {} from 'hast'
3-
4-
import type { BundledLanguage } from './assets/langs-bundle-web'
3+
import type { BundledLanguage } from './langs-bundle-web'
54
import type { BundledTheme } from './themes'
6-
import { bundledLanguages } from './assets/langs-bundle-web'
75
import { createdBundledHighlighter, createSingletonShorthands, warnDeprecated } from './core'
86
import { createOnigurumaEngine } from './engine-oniguruma'
7+
import { bundledLanguages } from './langs-bundle-web'
98
import { bundledThemes } from './themes'
10-
import { getWasmInlined } from './wasm-dynamic'
119

12-
export * from './assets/langs-bundle-web'
1310
export * from './core'
11+
export * from './langs-bundle-web'
1412
export * from './themes'
15-
16-
export { getWasmInlined }
13+
export { getWasmInlined } from './wasm-dynamic'
1714

1815
export type Highlighter = HighlighterGeneric<BundledLanguage, BundledTheme>
1916

‎packages/shiki/src/assets/langs-bundle-full.ts ‎packages/shiki/src/langs-bundle-full.ts

+212-212
Large diffs are not rendered by default.

‎packages/shiki/src/assets/langs-bundle-web.ts ‎packages/shiki/src/langs-bundle-web.ts

+51-51
Original file line numberDiff line numberDiff line change
@@ -5,222 +5,222 @@ export const bundledLanguagesInfo: BundledLanguageInfo[] = [
55
{
66
'id': 'angular-html',
77
'name': 'Angular HTML',
8-
'import': (() => import('./langs/angular-html')) as DynamicImportLanguageRegistration
8+
'import': (() => import('./langs/angular-html.mjs')) as DynamicImportLanguageRegistration
99
},
1010
{
1111
'id': 'angular-ts',
1212
'name': 'Angular TypeScript',
13-
'import': (() => import('./langs/angular-ts')) as DynamicImportLanguageRegistration
13+
'import': (() => import('./langs/angular-ts.mjs')) as DynamicImportLanguageRegistration
1414
},
1515
{
1616
'id': 'astro',
1717
'name': 'Astro',
18-
'import': (() => import('./langs/astro')) as DynamicImportLanguageRegistration
18+
'import': (() => import('./langs/astro.mjs')) as DynamicImportLanguageRegistration
1919
},
2020
{
2121
'id': 'blade',
2222
'name': 'Blade',
23-
'import': (() => import('./langs/blade')) as DynamicImportLanguageRegistration
23+
'import': (() => import('./langs/blade.mjs')) as DynamicImportLanguageRegistration
2424
},
2525
{
2626
'id': 'c',
2727
'name': 'C',
28-
'import': (() => import('./langs/c')) as DynamicImportLanguageRegistration
28+
'import': (() => import('./langs/c.mjs')) as DynamicImportLanguageRegistration
2929
},
3030
{
3131
'id': 'coffee',
3232
'name': 'CoffeeScript',
3333
'aliases': [
3434
'coffeescript'
3535
],
36-
'import': (() => import('./langs/coffee')) as DynamicImportLanguageRegistration
36+
'import': (() => import('./langs/coffee.mjs')) as DynamicImportLanguageRegistration
3737
},
3838
{
3939
'id': 'cpp',
4040
'name': 'C++',
4141
'aliases': [
4242
'c++'
4343
],
44-
'import': (() => import('./langs/cpp')) as DynamicImportLanguageRegistration
44+
'import': (() => import('./langs/cpp.mjs')) as DynamicImportLanguageRegistration
4545
},
4646
{
4747
'id': 'css',
4848
'name': 'CSS',
49-
'import': (() => import('./langs/css')) as DynamicImportLanguageRegistration
49+
'import': (() => import('./langs/css.mjs')) as DynamicImportLanguageRegistration
5050
},
5151
{
5252
'id': 'glsl',
5353
'name': 'GLSL',
54-
'import': (() => import('./langs/glsl')) as DynamicImportLanguageRegistration
54+
'import': (() => import('./langs/glsl.mjs')) as DynamicImportLanguageRegistration
5555
},
5656
{
5757
'id': 'graphql',
5858
'name': 'GraphQL',
5959
'aliases': [
6060
'gql'
6161
],
62-
'import': (() => import('./langs/graphql')) as DynamicImportLanguageRegistration
62+
'import': (() => import('./langs/graphql.mjs')) as DynamicImportLanguageRegistration
6363
},
6464
{
6565
'id': 'haml',
6666
'name': 'Ruby Haml',
67-
'import': (() => import('./langs/haml')) as DynamicImportLanguageRegistration
67+
'import': (() => import('./langs/haml.mjs')) as DynamicImportLanguageRegistration
6868
},
6969
{
7070
'id': 'handlebars',
7171
'name': 'Handlebars',
7272
'aliases': [
7373
'hbs'
7474
],
75-
'import': (() => import('./langs/handlebars')) as DynamicImportLanguageRegistration
75+
'import': (() => import('./langs/handlebars.mjs')) as DynamicImportLanguageRegistration
7676
},
7777
{
7878
'id': 'html',
7979
'name': 'HTML',
80-
'import': (() => import('./langs/html')) as DynamicImportLanguageRegistration
80+
'import': (() => import('./langs/html.mjs')) as DynamicImportLanguageRegistration
8181
},
8282
{
8383
'id': 'html-derivative',
8484
'name': 'HTML (Derivative)',
85-
'import': (() => import('./langs/html-derivative')) as DynamicImportLanguageRegistration
85+
'import': (() => import('./langs/html-derivative.mjs')) as DynamicImportLanguageRegistration
8686
},
8787
{
8888
'id': 'http',
8989
'name': 'HTTP',
90-
'import': (() => import('./langs/http')) as DynamicImportLanguageRegistration
90+
'import': (() => import('./langs/http.mjs')) as DynamicImportLanguageRegistration
9191
},
9292
{
9393
'id': 'imba',
9494
'name': 'Imba',
95-
'import': (() => import('./langs/imba')) as DynamicImportLanguageRegistration
95+
'import': (() => import('./langs/imba.mjs')) as DynamicImportLanguageRegistration
9696
},
9797
{
9898
'id': 'java',
9999
'name': 'Java',
100-
'import': (() => import('./langs/java')) as DynamicImportLanguageRegistration
100+
'import': (() => import('./langs/java.mjs')) as DynamicImportLanguageRegistration
101101
},
102102
{
103103
'id': 'javascript',
104104
'name': 'JavaScript',
105105
'aliases': [
106106
'js'
107107
],
108-
'import': (() => import('./langs/javascript')) as DynamicImportLanguageRegistration
108+
'import': (() => import('./langs/javascript.mjs')) as DynamicImportLanguageRegistration
109109
},
110110
{
111111
'id': 'jinja',
112112
'name': 'Jinja',
113-
'import': (() => import('./langs/jinja')) as DynamicImportLanguageRegistration
113+
'import': (() => import('./langs/jinja.mjs')) as DynamicImportLanguageRegistration
114114
},
115115
{
116116
'id': 'jison',
117117
'name': 'Jison',
118-
'import': (() => import('./langs/jison')) as DynamicImportLanguageRegistration
118+
'import': (() => import('./langs/jison.mjs')) as DynamicImportLanguageRegistration
119119
},
120120
{
121121
'id': 'json',
122122
'name': 'JSON',
123-
'import': (() => import('./langs/json')) as DynamicImportLanguageRegistration
123+
'import': (() => import('./langs/json.mjs')) as DynamicImportLanguageRegistration
124124
},
125125
{
126126
'id': 'jsonc',
127127
'name': 'JSON with Comments',
128-
'import': (() => import('./langs/jsonc')) as DynamicImportLanguageRegistration
128+
'import': (() => import('./langs/jsonc.mjs')) as DynamicImportLanguageRegistration
129129
},
130130
{
131131
'id': 'jsonl',
132132
'name': 'JSON Lines',
133-
'import': (() => import('./langs/jsonl')) as DynamicImportLanguageRegistration
133+
'import': (() => import('./langs/jsonl.mjs')) as DynamicImportLanguageRegistration
134134
},
135135
{
136136
'id': 'jsx',
137137
'name': 'JSX',
138-
'import': (() => import('./langs/jsx')) as DynamicImportLanguageRegistration
138+
'import': (() => import('./langs/jsx.mjs')) as DynamicImportLanguageRegistration
139139
},
140140
{
141141
'id': 'julia',
142142
'name': 'Julia',
143143
'aliases': [
144144
'jl'
145145
],
146-
'import': (() => import('./langs/julia')) as DynamicImportLanguageRegistration
146+
'import': (() => import('./langs/julia.mjs')) as DynamicImportLanguageRegistration
147147
},
148148
{
149149
'id': 'less',
150150
'name': 'Less',
151-
'import': (() => import('./langs/less')) as DynamicImportLanguageRegistration
151+
'import': (() => import('./langs/less.mjs')) as DynamicImportLanguageRegistration
152152
},
153153
{
154154
'id': 'markdown',
155155
'name': 'Markdown',
156156
'aliases': [
157157
'md'
158158
],
159-
'import': (() => import('./langs/markdown')) as DynamicImportLanguageRegistration
159+
'import': (() => import('./langs/markdown.mjs')) as DynamicImportLanguageRegistration
160160
},
161161
{
162162
'id': 'marko',
163163
'name': 'Marko',
164-
'import': (() => import('./langs/marko')) as DynamicImportLanguageRegistration
164+
'import': (() => import('./langs/marko.mjs')) as DynamicImportLanguageRegistration
165165
},
166166
{
167167
'id': 'mdc',
168168
'name': 'MDC',
169-
'import': (() => import('./langs/mdc')) as DynamicImportLanguageRegistration
169+
'import': (() => import('./langs/mdc.mjs')) as DynamicImportLanguageRegistration
170170
},
171171
{
172172
'id': 'mdx',
173173
'name': 'MDX',
174-
'import': (() => import('./langs/mdx')) as DynamicImportLanguageRegistration
174+
'import': (() => import('./langs/mdx.mjs')) as DynamicImportLanguageRegistration
175175
},
176176
{
177177
'id': 'php',
178178
'name': 'PHP',
179-
'import': (() => import('./langs/php')) as DynamicImportLanguageRegistration
179+
'import': (() => import('./langs/php.mjs')) as DynamicImportLanguageRegistration
180180
},
181181
{
182182
'id': 'postcss',
183183
'name': 'PostCSS',
184-
'import': (() => import('./langs/postcss')) as DynamicImportLanguageRegistration
184+
'import': (() => import('./langs/postcss.mjs')) as DynamicImportLanguageRegistration
185185
},
186186
{
187187
'id': 'pug',
188188
'name': 'Pug',
189189
'aliases': [
190190
'jade'
191191
],
192-
'import': (() => import('./langs/pug')) as DynamicImportLanguageRegistration
192+
'import': (() => import('./langs/pug.mjs')) as DynamicImportLanguageRegistration
193193
},
194194
{
195195
'id': 'python',
196196
'name': 'Python',
197197
'aliases': [
198198
'py'
199199
],
200-
'import': (() => import('./langs/python')) as DynamicImportLanguageRegistration
200+
'import': (() => import('./langs/python.mjs')) as DynamicImportLanguageRegistration
201201
},
202202
{
203203
'id': 'r',
204204
'name': 'R',
205-
'import': (() => import('./langs/r')) as DynamicImportLanguageRegistration
205+
'import': (() => import('./langs/r.mjs')) as DynamicImportLanguageRegistration
206206
},
207207
{
208208
'id': 'regexp',
209209
'name': 'RegExp',
210210
'aliases': [
211211
'regex'
212212
],
213-
'import': (() => import('./langs/regexp')) as DynamicImportLanguageRegistration
213+
'import': (() => import('./langs/regexp.mjs')) as DynamicImportLanguageRegistration
214214
},
215215
{
216216
'id': 'sass',
217217
'name': 'Sass',
218-
'import': (() => import('./langs/sass')) as DynamicImportLanguageRegistration
218+
'import': (() => import('./langs/sass.mjs')) as DynamicImportLanguageRegistration
219219
},
220220
{
221221
'id': 'scss',
222222
'name': 'SCSS',
223-
'import': (() => import('./langs/scss')) as DynamicImportLanguageRegistration
223+
'import': (() => import('./langs/scss.mjs')) as DynamicImportLanguageRegistration
224224
},
225225
{
226226
'id': 'shellscript',
@@ -231,79 +231,79 @@ export const bundledLanguagesInfo: BundledLanguageInfo[] = [
231231
'shell',
232232
'zsh'
233233
],
234-
'import': (() => import('./langs/shellscript')) as DynamicImportLanguageRegistration
234+
'import': (() => import('./langs/shellscript.mjs')) as DynamicImportLanguageRegistration
235235
},
236236
{
237237
'id': 'sql',
238238
'name': 'SQL',
239-
'import': (() => import('./langs/sql')) as DynamicImportLanguageRegistration
239+
'import': (() => import('./langs/sql.mjs')) as DynamicImportLanguageRegistration
240240
},
241241
{
242242
'id': 'stylus',
243243
'name': 'Stylus',
244244
'aliases': [
245245
'styl'
246246
],
247-
'import': (() => import('./langs/stylus')) as DynamicImportLanguageRegistration
247+
'import': (() => import('./langs/stylus.mjs')) as DynamicImportLanguageRegistration
248248
},
249249
{
250250
'id': 'svelte',
251251
'name': 'Svelte',
252-
'import': (() => import('./langs/svelte')) as DynamicImportLanguageRegistration
252+
'import': (() => import('./langs/svelte.mjs')) as DynamicImportLanguageRegistration
253253
},
254254
{
255255
'id': 'ts-tags',
256256
'name': 'TypeScript with Tags',
257257
'aliases': [
258258
'lit'
259259
],
260-
'import': (() => import('./langs/ts-tags')) as DynamicImportLanguageRegistration
260+
'import': (() => import('./langs/ts-tags.mjs')) as DynamicImportLanguageRegistration
261261
},
262262
{
263263
'id': 'tsx',
264264
'name': 'TSX',
265-
'import': (() => import('./langs/tsx')) as DynamicImportLanguageRegistration
265+
'import': (() => import('./langs/tsx.mjs')) as DynamicImportLanguageRegistration
266266
},
267267
{
268268
'id': 'typescript',
269269
'name': 'TypeScript',
270270
'aliases': [
271271
'ts'
272272
],
273-
'import': (() => import('./langs/typescript')) as DynamicImportLanguageRegistration
273+
'import': (() => import('./langs/typescript.mjs')) as DynamicImportLanguageRegistration
274274
},
275275
{
276276
'id': 'vue',
277277
'name': 'Vue',
278-
'import': (() => import('./langs/vue')) as DynamicImportLanguageRegistration
278+
'import': (() => import('./langs/vue.mjs')) as DynamicImportLanguageRegistration
279279
},
280280
{
281281
'id': 'vue-html',
282282
'name': 'Vue HTML',
283-
'import': (() => import('./langs/vue-html')) as DynamicImportLanguageRegistration
283+
'import': (() => import('./langs/vue-html.mjs')) as DynamicImportLanguageRegistration
284284
},
285285
{
286286
'id': 'wasm',
287287
'name': 'WebAssembly',
288-
'import': (() => import('./langs/wasm')) as DynamicImportLanguageRegistration
288+
'import': (() => import('./langs/wasm.mjs')) as DynamicImportLanguageRegistration
289289
},
290290
{
291291
'id': 'wgsl',
292292
'name': 'WGSL',
293-
'import': (() => import('./langs/wgsl')) as DynamicImportLanguageRegistration
293+
'import': (() => import('./langs/wgsl.mjs')) as DynamicImportLanguageRegistration
294294
},
295295
{
296296
'id': 'xml',
297297
'name': 'XML',
298-
'import': (() => import('./langs/xml')) as DynamicImportLanguageRegistration
298+
'import': (() => import('./langs/xml.mjs')) as DynamicImportLanguageRegistration
299299
},
300300
{
301301
'id': 'yaml',
302302
'name': 'YAML',
303303
'aliases': [
304304
'yml'
305305
],
306-
'import': (() => import('./langs/yaml')) as DynamicImportLanguageRegistration
306+
'import': (() => import('./langs/yaml.mjs')) as DynamicImportLanguageRegistration
307307
}
308308
]
309309

‎packages/shiki/src/langs.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export * from './assets/langs-bundle-full'
1+
export * from './langs-bundle-full'

‎packages/shiki/src/themes.ts

+366-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,366 @@
1-
export * from './assets/themes'
1+
// Generated by scripts/prepare.ts
2+
import type { DynamicImportThemeRegistration, BundledThemeInfo } from '@shikijs/core'
3+
4+
export const bundledThemesInfo: BundledThemeInfo[] = [
5+
{
6+
"id": "andromeeda",
7+
"displayName": "Andromeeda",
8+
"type": "dark",
9+
"import": (() => import('./themes/andromeeda.mjs')) as unknown as DynamicImportThemeRegistration
10+
},
11+
{
12+
"id": "aurora-x",
13+
"displayName": "Aurora X",
14+
"type": "dark",
15+
"import": (() => import('./themes/aurora-x.mjs')) as unknown as DynamicImportThemeRegistration
16+
},
17+
{
18+
"id": "ayu-dark",
19+
"displayName": "Ayu Dark",
20+
"type": "dark",
21+
"import": (() => import('./themes/ayu-dark.mjs')) as unknown as DynamicImportThemeRegistration
22+
},
23+
{
24+
"id": "catppuccin-frappe",
25+
"displayName": "Catppuccin Frappé",
26+
"type": "dark",
27+
"import": (() => import('./themes/catppuccin-frappe.mjs')) as unknown as DynamicImportThemeRegistration
28+
},
29+
{
30+
"id": "catppuccin-latte",
31+
"displayName": "Catppuccin Latte",
32+
"type": "light",
33+
"import": (() => import('./themes/catppuccin-latte.mjs')) as unknown as DynamicImportThemeRegistration
34+
},
35+
{
36+
"id": "catppuccin-macchiato",
37+
"displayName": "Catppuccin Macchiato",
38+
"type": "dark",
39+
"import": (() => import('./themes/catppuccin-macchiato.mjs')) as unknown as DynamicImportThemeRegistration
40+
},
41+
{
42+
"id": "catppuccin-mocha",
43+
"displayName": "Catppuccin Mocha",
44+
"type": "dark",
45+
"import": (() => import('./themes/catppuccin-mocha.mjs')) as unknown as DynamicImportThemeRegistration
46+
},
47+
{
48+
"id": "dark-plus",
49+
"displayName": "Dark Plus",
50+
"type": "dark",
51+
"import": (() => import('./themes/dark-plus.mjs')) as unknown as DynamicImportThemeRegistration
52+
},
53+
{
54+
"id": "dracula",
55+
"displayName": "Dracula Theme",
56+
"type": "dark",
57+
"import": (() => import('./themes/dracula.mjs')) as unknown as DynamicImportThemeRegistration
58+
},
59+
{
60+
"id": "dracula-soft",
61+
"displayName": "Dracula Theme Soft",
62+
"type": "dark",
63+
"import": (() => import('./themes/dracula-soft.mjs')) as unknown as DynamicImportThemeRegistration
64+
},
65+
{
66+
"id": "everforest-dark",
67+
"displayName": "Everforest Dark",
68+
"type": "dark",
69+
"import": (() => import('./themes/everforest-dark.mjs')) as unknown as DynamicImportThemeRegistration
70+
},
71+
{
72+
"id": "everforest-light",
73+
"displayName": "Everforest Light",
74+
"type": "light",
75+
"import": (() => import('./themes/everforest-light.mjs')) as unknown as DynamicImportThemeRegistration
76+
},
77+
{
78+
"id": "github-dark",
79+
"displayName": "GitHub Dark",
80+
"type": "dark",
81+
"import": (() => import('./themes/github-dark.mjs')) as unknown as DynamicImportThemeRegistration
82+
},
83+
{
84+
"id": "github-dark-default",
85+
"displayName": "GitHub Dark Default",
86+
"type": "dark",
87+
"import": (() => import('./themes/github-dark-default.mjs')) as unknown as DynamicImportThemeRegistration
88+
},
89+
{
90+
"id": "github-dark-dimmed",
91+
"displayName": "GitHub Dark Dimmed",
92+
"type": "dark",
93+
"import": (() => import('./themes/github-dark-dimmed.mjs')) as unknown as DynamicImportThemeRegistration
94+
},
95+
{
96+
"id": "github-dark-high-contrast",
97+
"displayName": "GitHub Dark High Contrast",
98+
"type": "dark",
99+
"import": (() => import('./themes/github-dark-high-contrast.mjs')) as unknown as DynamicImportThemeRegistration
100+
},
101+
{
102+
"id": "github-light",
103+
"displayName": "GitHub Light",
104+
"type": "light",
105+
"import": (() => import('./themes/github-light.mjs')) as unknown as DynamicImportThemeRegistration
106+
},
107+
{
108+
"id": "github-light-default",
109+
"displayName": "GitHub Light Default",
110+
"type": "light",
111+
"import": (() => import('./themes/github-light-default.mjs')) as unknown as DynamicImportThemeRegistration
112+
},
113+
{
114+
"id": "github-light-high-contrast",
115+
"displayName": "GitHub Light High Contrast",
116+
"type": "light",
117+
"import": (() => import('./themes/github-light-high-contrast.mjs')) as unknown as DynamicImportThemeRegistration
118+
},
119+
{
120+
"id": "houston",
121+
"displayName": "Houston",
122+
"type": "dark",
123+
"import": (() => import('./themes/houston.mjs')) as unknown as DynamicImportThemeRegistration
124+
},
125+
{
126+
"id": "laserwave",
127+
"displayName": "LaserWave",
128+
"type": "dark",
129+
"import": (() => import('./themes/laserwave.mjs')) as unknown as DynamicImportThemeRegistration
130+
},
131+
{
132+
"id": "light-plus",
133+
"displayName": "Light Plus",
134+
"type": "light",
135+
"import": (() => import('./themes/light-plus.mjs')) as unknown as DynamicImportThemeRegistration
136+
},
137+
{
138+
"id": "material-theme",
139+
"displayName": "Material Theme",
140+
"type": "dark",
141+
"import": (() => import('./themes/material-theme.mjs')) as unknown as DynamicImportThemeRegistration
142+
},
143+
{
144+
"id": "material-theme-darker",
145+
"displayName": "Material Theme Darker",
146+
"type": "dark",
147+
"import": (() => import('./themes/material-theme-darker.mjs')) as unknown as DynamicImportThemeRegistration
148+
},
149+
{
150+
"id": "material-theme-lighter",
151+
"displayName": "Material Theme Lighter",
152+
"type": "light",
153+
"import": (() => import('./themes/material-theme-lighter.mjs')) as unknown as DynamicImportThemeRegistration
154+
},
155+
{
156+
"id": "material-theme-ocean",
157+
"displayName": "Material Theme Ocean",
158+
"type": "dark",
159+
"import": (() => import('./themes/material-theme-ocean.mjs')) as unknown as DynamicImportThemeRegistration
160+
},
161+
{
162+
"id": "material-theme-palenight",
163+
"displayName": "Material Theme Palenight",
164+
"type": "dark",
165+
"import": (() => import('./themes/material-theme-palenight.mjs')) as unknown as DynamicImportThemeRegistration
166+
},
167+
{
168+
"id": "min-dark",
169+
"displayName": "Min Dark",
170+
"type": "dark",
171+
"import": (() => import('./themes/min-dark.mjs')) as unknown as DynamicImportThemeRegistration
172+
},
173+
{
174+
"id": "min-light",
175+
"displayName": "Min Light",
176+
"type": "light",
177+
"import": (() => import('./themes/min-light.mjs')) as unknown as DynamicImportThemeRegistration
178+
},
179+
{
180+
"id": "monokai",
181+
"displayName": "Monokai",
182+
"type": "dark",
183+
"import": (() => import('./themes/monokai.mjs')) as unknown as DynamicImportThemeRegistration
184+
},
185+
{
186+
"id": "night-owl",
187+
"displayName": "Night Owl",
188+
"type": "dark",
189+
"import": (() => import('./themes/night-owl.mjs')) as unknown as DynamicImportThemeRegistration
190+
},
191+
{
192+
"id": "nord",
193+
"displayName": "Nord",
194+
"type": "dark",
195+
"import": (() => import('./themes/nord.mjs')) as unknown as DynamicImportThemeRegistration
196+
},
197+
{
198+
"id": "one-dark-pro",
199+
"displayName": "One Dark Pro",
200+
"type": "dark",
201+
"import": (() => import('./themes/one-dark-pro.mjs')) as unknown as DynamicImportThemeRegistration
202+
},
203+
{
204+
"id": "one-light",
205+
"displayName": "One Light",
206+
"type": "light",
207+
"import": (() => import('./themes/one-light.mjs')) as unknown as DynamicImportThemeRegistration
208+
},
209+
{
210+
"id": "plastic",
211+
"displayName": "Plastic",
212+
"type": "dark",
213+
"import": (() => import('./themes/plastic.mjs')) as unknown as DynamicImportThemeRegistration
214+
},
215+
{
216+
"id": "poimandres",
217+
"displayName": "Poimandres",
218+
"type": "dark",
219+
"import": (() => import('./themes/poimandres.mjs')) as unknown as DynamicImportThemeRegistration
220+
},
221+
{
222+
"id": "red",
223+
"displayName": "Red",
224+
"type": "dark",
225+
"import": (() => import('./themes/red.mjs')) as unknown as DynamicImportThemeRegistration
226+
},
227+
{
228+
"id": "rose-pine",
229+
"displayName": "Rosé Pine",
230+
"type": "dark",
231+
"import": (() => import('./themes/rose-pine.mjs')) as unknown as DynamicImportThemeRegistration
232+
},
233+
{
234+
"id": "rose-pine-dawn",
235+
"displayName": "Rosé Pine Dawn",
236+
"type": "light",
237+
"import": (() => import('./themes/rose-pine-dawn.mjs')) as unknown as DynamicImportThemeRegistration
238+
},
239+
{
240+
"id": "rose-pine-moon",
241+
"displayName": "Rosé Pine Moon",
242+
"type": "dark",
243+
"import": (() => import('./themes/rose-pine-moon.mjs')) as unknown as DynamicImportThemeRegistration
244+
},
245+
{
246+
"id": "slack-dark",
247+
"displayName": "Slack Dark",
248+
"type": "dark",
249+
"import": (() => import('./themes/slack-dark.mjs')) as unknown as DynamicImportThemeRegistration
250+
},
251+
{
252+
"id": "slack-ochin",
253+
"displayName": "Slack Ochin",
254+
"type": "light",
255+
"import": (() => import('./themes/slack-ochin.mjs')) as unknown as DynamicImportThemeRegistration
256+
},
257+
{
258+
"id": "snazzy-light",
259+
"displayName": "Snazzy Light",
260+
"type": "light",
261+
"import": (() => import('./themes/snazzy-light.mjs')) as unknown as DynamicImportThemeRegistration
262+
},
263+
{
264+
"id": "solarized-dark",
265+
"displayName": "Solarized Dark",
266+
"type": "dark",
267+
"import": (() => import('./themes/solarized-dark.mjs')) as unknown as DynamicImportThemeRegistration
268+
},
269+
{
270+
"id": "solarized-light",
271+
"displayName": "Solarized Light",
272+
"type": "light",
273+
"import": (() => import('./themes/solarized-light.mjs')) as unknown as DynamicImportThemeRegistration
274+
},
275+
{
276+
"id": "synthwave-84",
277+
"displayName": "Synthwave '84",
278+
"type": "dark",
279+
"import": (() => import('./themes/synthwave-84.mjs')) as unknown as DynamicImportThemeRegistration
280+
},
281+
{
282+
"id": "tokyo-night",
283+
"displayName": "Tokyo Night",
284+
"type": "dark",
285+
"import": (() => import('./themes/tokyo-night.mjs')) as unknown as DynamicImportThemeRegistration
286+
},
287+
{
288+
"id": "vesper",
289+
"displayName": "Vesper",
290+
"type": "dark",
291+
"import": (() => import('./themes/vesper.mjs')) as unknown as DynamicImportThemeRegistration
292+
},
293+
{
294+
"id": "vitesse-black",
295+
"displayName": "Vitesse Black",
296+
"type": "dark",
297+
"import": (() => import('./themes/vitesse-black.mjs')) as unknown as DynamicImportThemeRegistration
298+
},
299+
{
300+
"id": "vitesse-dark",
301+
"displayName": "Vitesse Dark",
302+
"type": "dark",
303+
"import": (() => import('./themes/vitesse-dark.mjs')) as unknown as DynamicImportThemeRegistration
304+
},
305+
{
306+
"id": "vitesse-light",
307+
"displayName": "Vitesse Light",
308+
"type": "light",
309+
"import": (() => import('./themes/vitesse-light.mjs')) as unknown as DynamicImportThemeRegistration
310+
}
311+
]
312+
313+
export type BundledTheme =
314+
| 'andromeeda'
315+
| 'aurora-x'
316+
| 'ayu-dark'
317+
| 'catppuccin-frappe'
318+
| 'catppuccin-latte'
319+
| 'catppuccin-macchiato'
320+
| 'catppuccin-mocha'
321+
| 'dark-plus'
322+
| 'dracula'
323+
| 'dracula-soft'
324+
| 'everforest-dark'
325+
| 'everforest-light'
326+
| 'github-dark'
327+
| 'github-dark-default'
328+
| 'github-dark-dimmed'
329+
| 'github-dark-high-contrast'
330+
| 'github-light'
331+
| 'github-light-default'
332+
| 'github-light-high-contrast'
333+
| 'houston'
334+
| 'laserwave'
335+
| 'light-plus'
336+
| 'material-theme'
337+
| 'material-theme-darker'
338+
| 'material-theme-lighter'
339+
| 'material-theme-ocean'
340+
| 'material-theme-palenight'
341+
| 'min-dark'
342+
| 'min-light'
343+
| 'monokai'
344+
| 'night-owl'
345+
| 'nord'
346+
| 'one-dark-pro'
347+
| 'one-light'
348+
| 'plastic'
349+
| 'poimandres'
350+
| 'red'
351+
| 'rose-pine'
352+
| 'rose-pine-dawn'
353+
| 'rose-pine-moon'
354+
| 'slack-dark'
355+
| 'slack-ochin'
356+
| 'snazzy-light'
357+
| 'solarized-dark'
358+
| 'solarized-light'
359+
| 'synthwave-84'
360+
| 'tokyo-night'
361+
| 'vesper'
362+
| 'vitesse-black'
363+
| 'vitesse-dark'
364+
| 'vitesse-light'
365+
366+
export const bundledThemes = Object.fromEntries(bundledThemesInfo.map(i => [i.id, i.import])) as Record<BundledTheme, DynamicImportThemeRegistration>

‎packages/shiki/test/core-sync.test.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { describe, expect, it } from 'vitest'
2-
import js from '../src/assets/langs/javascript'
3-
4-
import nord from '../src/assets/themes/nord'
5-
import { createHighlighterCoreSync, createJavaScriptRegexEngine } from '../src/core'
2+
import { createJavaScriptRegexEngine } from '../../engine-javascript/src'
3+
import { createHighlighterCoreSync } from '../src/core'
4+
import js from '../src/langs/javascript.mjs'
5+
import nord from '../src/themes/nord.mjs'
66

77
describe('should', () => {
88
const engine = createJavaScriptRegexEngine()
@@ -24,12 +24,12 @@ describe('should', () => {
2424
langs: [
2525
js,
2626
// Load the grammar upfront (await outside of the function)
27-
await import('../src/assets/langs/c').then(r => r.default),
27+
await import('../src/langs/c.mjs').then(r => r.default),
2828
],
2929
engine,
3030
})
3131

32-
shiki.loadLanguageSync(await import('../src/assets/langs/python').then(m => m.default))
32+
shiki.loadLanguageSync(await import('../src/langs/python.mjs').then(m => m.default))
3333
shiki.loadThemeSync(await import('../dist/themes/vitesse-light.mjs').then(m => m.default))
3434

3535
expect(shiki.getLoadedLanguages())

‎packages/shiki/test/core.test.ts

+7-8
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,11 @@ import { describe, expect, it } from 'vitest'
22
// eslint-disable-next-line antfu/no-import-dist
33
import { wasmBinary } from '../../engine-oniguruma/dist/wasm-inlined.mjs'
44

5-
import js from '../src/assets/langs/javascript'
6-
import ts from '../src/assets/langs/typescript'
7-
import mtp from '../src/assets/themes/material-theme-palenight'
8-
import nord from '../src/assets/themes/nord'
9-
105
import { createHighlighterCore } from '../src/core'
6+
import js from '../src/langs/javascript.mjs'
7+
import ts from '../src/langs/typescript.mjs'
8+
import mtp from '../src/themes/material-theme-palenight.mjs'
9+
import nord from '../src/themes/nord.mjs'
1110

1211
describe('should', () => {
1312
it('works', async () => {
@@ -28,15 +27,15 @@ describe('should', () => {
2827
themes: [nord],
2928
langs: [
3029
js,
31-
import('../src/assets/langs/c'),
30+
import('../src/langs/c.mjs'),
3231
],
3332
loadWasm: {
3433
// https://github.com/WebAssembly/esm-integration/tree/main/proposals/esm-integration
3534
instantiator: obj => WebAssembly.instantiate(wasmBinary, obj).then(r => r.instance.exports),
3635
},
3736
})
3837

39-
await shiki.loadLanguage(() => import('../src/assets/langs/python'))
38+
await shiki.loadLanguage(() => import('../src/langs/python.mjs'))
4039
await shiki.loadTheme(() => import('../dist/themes/vitesse-light.mjs').then(m => m.default))
4140

4241
expect(shiki.getLoadedLanguages())
@@ -65,7 +64,7 @@ describe('should', () => {
6564
const shiki = await createHighlighterCore({
6665
themes: [nord],
6766
langs: [
68-
import('../src/assets/langs/cpp'),
67+
import('../src/langs/cpp.mjs'),
6968
],
7069
})
7170

‎packages/shiki/test/get-highlighter.test.ts

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
import { getSingletonHighlighter } from 'shiki'
22
import { expect, it } from 'vitest'
3-
import js from '../src/assets/langs/javascript'
4-
import mtp from '../src/assets/themes/material-theme-palenight'
5-
import nord from '../src/assets/themes/nord'
6-
73
import { getSingletonHighlighterCore } from '../src/core'
4+
import js from '../src/langs/javascript.mjs'
5+
import mtp from '../src/themes/material-theme-palenight.mjs'
6+
import nord from '../src/themes/nord.mjs'
87

98
it('getSingletonHighlighterCore', async () => {
109
const shiki1 = await getSingletonHighlighterCore({

‎packages/shiki/test/injections.test.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import { codeToHtml, createHighlighterCore } from 'shiki'
22
import { expect, it } from 'vitest'
3-
import angularHtml from '../src/assets/langs/angular-html'
4-
import angularTs from '../src/assets/langs/angular-ts'
5-
import html from '../src/assets/langs/html'
6-
import ts from '../src/assets/langs/typescript'
7-
import vue from '../src/assets/langs/vue'
8-
import vl from '../src/assets/themes/vitesse-light'
3+
import angularHtml from '../src/langs/angular-html.mjs'
4+
import angularTs from '../src/langs/angular-ts.mjs'
5+
import html from '../src/langs/html.mjs'
6+
import ts from '../src/langs/typescript.mjs'
7+
import vue from '../src/langs/vue.mjs'
8+
import vl from '../src/themes/vitesse-light.mjs'
99

1010
// Basically we need to make sure that the syntax inside `v-if` and `{{}}` is highlighted correctly.
1111
// This is done by a `vue-injections` patch that injects extra grammar into HTML.

‎packages/shiki/test/wasm1.test.ts

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
import { expect, it } from 'vitest'
22
// eslint-disable-next-line antfu/no-import-dist
33
import { wasmBinary } from '../../engine-oniguruma/dist/wasm-inlined.mjs'
4-
5-
import js from '../src/assets/langs/javascript'
6-
import nord from '../src/assets/themes/nord'
7-
84
import { createHighlighterCore } from '../src/core'
5+
import js from '../src/langs/javascript.mjs'
6+
import nord from '../src/themes/nord.mjs'
97

108
it('wasm', async () => {
119
const shiki = await createHighlighterCore({

‎packages/shiki/test/wasm2.test.ts

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
import { expect, it } from 'vitest'
22
// eslint-disable-next-line antfu/no-import-dist
33
import { wasmBinary } from '../../engine-oniguruma/dist/wasm-inlined.mjs'
4-
5-
import js from '../src/assets/langs/javascript'
6-
import nord from '../src/assets/themes/nord'
7-
84
import { createHighlighterCore } from '../src/core'
5+
import js from '../src/langs/javascript.mjs'
6+
import nord from '../src/themes/nord.mjs'
97

108
it('wasm', async () => {
119
const shiki = await createHighlighterCore({

‎packages/shiki/test/wasm3.test.ts

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
import { expect, it } from 'vitest'
22
// eslint-disable-next-line antfu/no-import-dist
33
import { wasmBinary } from '../../engine-oniguruma/dist/wasm-inlined.mjs'
4-
5-
import js from '../src/assets/langs/javascript'
6-
import nord from '../src/assets/themes/nord'
7-
84
import { createHighlighterCore } from '../src/core'
5+
import js from '../src/langs/javascript.mjs'
6+
import nord from '../src/themes/nord.mjs'
97

108
it('wasm', async () => {
119
const shiki = await createHighlighterCore({

‎packages/shiki/test/wasm4.test.ts

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
import { expect, it } from 'vitest'
22
// eslint-disable-next-line antfu/no-import-dist
33
import { wasmBinary } from '../../engine-oniguruma/dist/wasm-inlined.mjs'
4-
5-
import js from '../src/assets/langs/javascript'
6-
import nord from '../src/assets/themes/nord'
7-
84
import { createHighlighterCore } from '../src/core'
5+
import js from '../src/langs/javascript.mjs'
6+
import nord from '../src/themes/nord.mjs'
97

108
it('wasm', async () => {
119
const shiki = await createHighlighterCore({

‎packages/shiki/test/wasm5.test.ts

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
import { expect, it } from 'vitest'
22
// eslint-disable-next-line antfu/no-import-dist
33
import { wasmBinary } from '../../engine-oniguruma/dist/wasm-inlined.mjs'
4-
5-
import js from '../src/assets/langs/javascript'
6-
import nord from '../src/assets/themes/nord'
7-
84
import { createHighlighterCore } from '../src/core'
5+
import js from '../src/langs/javascript.mjs'
6+
import nord from '../src/themes/nord.mjs'
97

108
it('loadWasm: WebAssembly.Module', async () => {
119
const shiki = await createHighlighterCore({

‎packages/shiki/test/wasm6.test.ts

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
import { expect, it } from 'vitest'
22
// eslint-disable-next-line antfu/no-import-dist
33
import { wasmBinary } from '../../engine-oniguruma/dist/wasm-inlined.mjs'
4-
5-
import js from '../src/assets/langs/javascript'
6-
import nord from '../src/assets/themes/nord'
7-
84
import { createHighlighterCore } from '../src/core'
5+
import js from '../src/langs/javascript.mjs'
6+
import nord from '../src/themes/nord.mjs'
97

108
it('loadWasm: { default: WebAssembly.Module }', async () => {
119
const shiki = await createHighlighterCore({

‎pnpm-lock.yaml

+3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎vitest.config.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ export default defineConfig({
4545

4646
// Vendored code
4747
'packages/engine-oniguruma/src/oniguruma/onig.ts',
48-
'**/src/assets/**',
48+
'**/src/langs/**',
49+
'**/src/themes/**',
4950
'**/wasm-inlined.ts',
5051

5152
// Integration packages that are hard to cover, or tested elsewhere

0 commit comments

Comments
 (0)
Please sign in to comment.