mirror of
https://github.com/BetterSEQTA/BetterSEQTA-Plus.git
synced 2026-08-28 09:11:06 +00:00
4fda63dedd
Extract shared helpers for home notices, timetable subtitles, and theme images; dedupe global search, Select, and build scripts while preserving behaviour. Add @huggingface/transformers as a direct dependency and resolve ORT WASM paths via require.resolve so pnpm postinstall and Vite can bundle vector search. Co-authored-by: Cursor <cursoragent@cursor.com>
33 lines
985 B
TypeScript
33 lines
985 B
TypeScript
import { Plugin } from "vite";
|
|
import { build } from "esbuild";
|
|
|
|
/** Bundle worker entry points imported with `?inlineWorker` as Blob-backed Workers in dev. */
|
|
export default function InlineWorkerDevPlugin(): Plugin {
|
|
return {
|
|
name: "vite:inline-worker-dev",
|
|
async load(id) {
|
|
if (!id.includes("?inlineWorker")) return null;
|
|
|
|
const [cleanPath] = id.split("?");
|
|
const result = await build({
|
|
entryPoints: [cleanPath],
|
|
bundle: true,
|
|
write: false,
|
|
platform: "browser",
|
|
format: "iife",
|
|
target: "esnext",
|
|
external: ["webextension-polyfill"],
|
|
});
|
|
|
|
const workerCode = result.outputFiles[0].text;
|
|
return `
|
|
const code = ${JSON.stringify(workerCode)};
|
|
export default function InlineWorker() {
|
|
const blob = new Blob([code], { type: 'application/javascript' });
|
|
return new Worker(URL.createObjectURL(blob), { type: 'module' });
|
|
}
|
|
`;
|
|
},
|
|
};
|
|
}
|