Files
BetterSEQTA-Plus/scripts/copy-ort-wasm-assets.mjs
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

29 lines
899 B
JavaScript

import { copyFileSync, existsSync, mkdirSync } from "node:fs";
import { createRequire } from "node:module";
import { dirname, join } from "node:path";
import { fileURLToPath } from "node:url";
const root = join(dirname(fileURLToPath(import.meta.url)), "..");
const require = createRequire(import.meta.url);
const transformersDist = dirname(require.resolve("@huggingface/transformers"));
const outDir = join(root, "src", "public", "resources", "ort");
mkdirSync(outDir, { recursive: true });
const ortFiles = [
"ort-wasm-simd-threaded.jsep.mjs",
"ort-wasm-simd-threaded.jsep.wasm",
];
for (const file of ortFiles) {
const src = join(transformersDist, file);
if (!existsSync(src)) {
throw new Error(
`Missing ONNX Runtime WASM asset: ${src}\n` +
"Ensure @huggingface/transformers is installed (direct dependency).",
);
}
copyFileSync(src, join(outDir, file));
}