Skip to content

armgit / kaneo

Public Imported from GitHub
0

⚡ Project management that doesn't become the project. Boards, Gantt charts, and GitHub integration. Self-host it or use Kaneo Cloud.

fix(web): use Shiki's JavaScript regex engine to avoid WebAssembly

Justin Lui09fb5d446d68
diff --git a/apps/web/src/lib/shiki-highlighter.ts b/apps/web/src/lib/shiki-highlighter.ts
index 63273f673..49b67538b 100644
--- a/apps/web/src/lib/shiki-highlighter.ts
+++ b/apps/web/src/lib/shiki-highlighter.ts
@@ -1,4 +1,5 @@
import { createHighlighter, type Highlighter } from "shiki";
+import { createJavaScriptRegexEngine } from "shiki/engine/javascript";
let shikiHighlighterPromise: Promise<Highlighter> | null = null;
@@ -45,6 +46,15 @@ export function getSharedShikiHighlighter() {
shikiHighlighterPromise = createHighlighter({
themes: ["github-dark", "github-light"],
langs: [...SHIKI_LANGUAGES],
+ // The default oniguruma engine runs on WebAssembly, which Chrome
+ // enterprise policies (e.g. JavaScriptJitDisabled) can disable. With
+ // WASM disabled, createHighlighter rejects and views waiting on it
+ // never render.
+ // The JavaScript engine doesn't require WASM. `forgiving` means a
+ // pattern that can't be translated to a native RegExp stops matching
+ // (worst case: one token type unhighlighted) instead of throwing at
+ // creation. All bundled grammars translate as of Shiki 3.9.1.
+ engine: createJavaScriptRegexEngine({ forgiving: true }),
});
}