Skip to content

Commit 5b708fc

Browse files
Merge pull request #658 from thejackshelton/fix-website-cf
fix(website): only bundle what we use for shiki
2 parents 0457f60 + d384806 commit 5b708fc

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

apps/website/src/components/highlight/highlight.tsx

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import { ClassList, PropsOf, component$, useSignal, useTask$ } from '@builder.io/qwik';
22
import { CodeCopy } from '../code-copy/code-copy';
3-
import { codeToHtml } from 'shiki';
3+
import { getHighlighterCore } from 'shiki';
44
import { cn } from '@qwik-ui/utils';
5+
import getWasm from 'shiki/wasm';
56

67
export type HighlightProps = PropsOf<'div'> & {
78
code: string;
@@ -36,7 +37,20 @@ export const Highlight = component$(
3637
modifiedCode = partsOfCode[0];
3738
}
3839

39-
const str = await codeToHtml(modifiedCode, {
40+
const highlighter = await getHighlighterCore({
41+
themes: [
42+
// or a dynamic import if you want to do chunk splitting
43+
import('shiki/themes/poimandres.mjs'),
44+
],
45+
langs: [
46+
import('shiki/langs/html.mjs'),
47+
import('shiki/langs/tsx.mjs'),
48+
import('shiki/langs/css.mjs'),
49+
],
50+
loadWasm: getWasm,
51+
});
52+
53+
const str = highlighter.codeToHtml(modifiedCode, {
4054
lang: language,
4155
themes: {
4256
light: 'poimandres',

0 commit comments

Comments
 (0)