Files
BetterSEQTA-Plus/lib/inlineWorker.ts
T
AdenMGB 4fda63dedd refactor: trim PR debloat and fix transformers build
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>
2026-06-28 10:30:25 +09:30

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' });
}
`;
},
};
}