Adds a 2-worker pool in use-syntax-highlight.ts so shiki tokenisation runs off the main thread. Callers continue to receive null while the worker is in flight and a LineTokenMap once it resolves — no caller changes needed. Fallback: if Worker construction is blocked (e.g. CSP), the hook falls back to the existing createHighlighter singleton but processes 200 lines at a time, yielding between chunks via scheduler.yield()/setTimeout(0) to avoid long tasks. Also adds worker.format:'es' to vite.config.ts (required when the app uses code-splitting) and covers all paths with Vitest tests. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
27 lines
672 B
TypeScript
27 lines
672 B
TypeScript
import path from "node:path";
|
|
import { defineConfig } from "vite";
|
|
import { TanStackRouterVite } from "@tanstack/router-plugin/vite";
|
|
import react from "@vitejs/plugin-react";
|
|
|
|
export default defineConfig({
|
|
plugins: [TanStackRouterVite({ autoCodeSplitting: true }), react()],
|
|
resolve: {
|
|
alias: {
|
|
"@": path.resolve(__dirname, "./src"),
|
|
},
|
|
},
|
|
worker: {
|
|
// ES module workers are required when the app uses code-splitting (Rollup
|
|
// can't bundle IIFE workers alongside dynamic imports).
|
|
format: "es",
|
|
},
|
|
server: {
|
|
proxy: {
|
|
"/trpc": {
|
|
target: "http://127.0.0.1:3847",
|
|
changeOrigin: true,
|
|
},
|
|
},
|
|
},
|
|
});
|