Skip to content

Commit f992e94

Browse files
authored
Merge pull request #668 from maiieul/fix-shiki-memory
fix random "memory access out of bounds" shiki bug
2 parents 99a4e0d + 7452958 commit f992e94

File tree

12 files changed

+37
-39
lines changed

12 files changed

+37
-39
lines changed

apps/component-tests/tsconfig.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
"compilerOptions": {
44
"allowJs": true,
55
"target": "ES2017",
6-
"module": "ES2020",
7-
"lib": ["es2020", "DOM", "WebWorker", "DOM.Iterable"],
6+
"module": "ES2022",
7+
"lib": ["es2022", "DOM", "WebWorker", "DOM.Iterable"],
88
"jsx": "react-jsx",
99
"jsxImportSource": "@builder.io/qwik",
1010
"strict": true,

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

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

76
export type HighlightProps = PropsOf<'div'> & {
87
code: string;
@@ -23,7 +22,6 @@ export const Highlight = component$(
2322
}: HighlightProps) => {
2423
const codeSig = useSignal('');
2524

26-
// eslint-disable-next-line qwik/no-use-visible-task
2725
useTask$(async function createHighlightedCode() {
2826
let modifiedCode: string = code;
2927

@@ -37,19 +35,6 @@ export const Highlight = component$(
3735
modifiedCode = partsOfCode[0];
3836
}
3937

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-
5338
const str = highlighter.codeToHtml(modifiedCode, {
5439
lang: language,
5540
themes: {
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { getHighlighterCore } from 'shiki/index.mjs';
2+
import getWasm from 'shiki/wasm';
3+
import poimandres from 'shiki/themes/poimandres.mjs';
4+
import html from 'shiki/langs/html.mjs';
5+
import css from 'shiki/langs/css.mjs';
6+
import ts from 'shiki/langs/typescript.mjs';
7+
import tsx from 'shiki/langs/tsx.mjs';
8+
import js from 'shiki/langs/javascript.mjs';
9+
10+
export const highlighter = await getHighlighterCore({
11+
themes: [
12+
// or a dynamic import if you want to do chunk splitting
13+
poimandres,
14+
],
15+
langs: [html, css, js, ts, tsx],
16+
loadWasm: getWasm,
17+
});

apps/website/tsconfig.app.json

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,6 @@
55
"outDir": "../../dist/out-tsc"
66
},
77
"files": [],
8-
"exclude": [],
9-
"include": [
10-
"**/*.js",
11-
"**/*.jsx",
12-
"**/*.ts",
13-
"**/*.tsx",
14-
"src/routes/docs/headless/introduction/index.mdx",
15-
"tailwind.config.cjs"
16-
]
8+
"exclude": ["tailwind.config.cjs"],
9+
"include": ["**/*.js", "**/*.jsx", "**/*.ts", "**/*.tsx"]
1710
}

apps/website/tsconfig.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
"compilerOptions": {
44
"allowJs": true,
55
"target": "ES2017",
6-
"module": "ES2020",
7-
"lib": ["es2020", "DOM", "WebWorker", "DOM.Iterable"],
6+
"module": "ES2022",
7+
"lib": ["ES2022", "DOM", "WebWorker", "DOM.Iterable"],
88
"jsx": "react-jsx",
99
"jsxImportSource": "@builder.io/qwik",
1010
"strict": true,

apps/website/vite.config.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,9 @@ export default defineConfig(async () => {
9999
allow: ['../../'],
100100
},
101101
},
102+
build: {
103+
target: 'es2022',
104+
},
102105
preview: {
103106
headers: {
104107
'Cache-Control': 'public, max-age=600',

packages/kit-headless/tsconfig.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
"compilerOptions": {
44
"allowJs": true,
55
"target": "ES2017",
6-
"module": "ES2020",
7-
"lib": ["es2020", "DOM", "WebWorker", "DOM.Iterable"],
6+
"module": "ES2022",
7+
"lib": ["ES2022", "DOM", "WebWorker", "DOM.Iterable"],
88
"jsx": "react-jsx",
99
"jsxImportSource": "@builder.io/qwik",
1010
"forceConsistentCasingInFileNames": true,

packages/kit-headless/vite.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ export default defineConfig({
4848
// Configuration for building your library.
4949
// See: https://vitejs.dev/guide/build.html#library-mode
5050
build: {
51-
target: 'es2020',
51+
target: 'es2022',
5252
lib: {
5353
entry: './src/index.ts',
5454
// Could also be a dictionary or array of multiple entry points.

packages/kit-styled/tsconfig.generators.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"compilerOptions": {
44
"outDir": "../../dist/out-tsc",
55
"declaration": true,
6-
"module": "commonjs",
6+
"module": "ES2022",
77
"types": ["node"]
88
},
99
"files": [],

packages/kit-styled/tsconfig.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
"compilerOptions": {
44
"allowJs": true,
55
"target": "ES2017",
6-
"module": "ES2020",
7-
"lib": ["es2020", "DOM", "WebWorker", "DOM.Iterable"],
6+
"module": "ES2022",
7+
"lib": ["ES2022", "DOM", "WebWorker", "DOM.Iterable"],
88
"jsx": "react-jsx",
99
"jsxImportSource": "@builder.io/qwik",
1010
"forceConsistentCasingInFileNames": true,

0 commit comments

Comments
 (0)