Files
whisper_web/scripts/ortAlias.ts
T
Lucas WintherandClaude Opus 5.5 708fae5778 Run Parakeet TDT in the inference worker via parakeet.js on the shared onnxruntime-web
Adds parakeet.js 1.4.4 (MIT) as a devDependency bundled into the worker
only; a build plugin keeps its own onnxruntime-web copy out of the bundle.
Includes an opt-in real-model test (PARAKEET_REAL=1).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-29 22:08:05 +01:00

24 lines
872 B
TypeScript

/**
* Bun build plugin: parakeet.js's bare `onnxruntime-web` import resolves to
* `src/worker/ortShim.ts` (= Transformers.js's `onnxruntime-web/webgpu`), so
* the inference worker bundles exactly one onnxruntime (D-WS7a). Used by the
* production build (scripts/build.ts) and the dev server's worker bundle
* (src/index.ts). Without it the bundle carries parakeet.js's own 1.24.1
* copy as well — never executed, but ~0.5 MB of dead weight and a CDN
* wasmPaths default.
*/
import type { BunPlugin } from "bun";
import { join } from "node:path";
const SHIM = join(import.meta.dir, "../src/worker/ortShim.ts");
export const ortAliasPlugin: BunPlugin = {
name: "parakeet-ort-alias",
setup(build) {
build.onResolve({ filter: /^onnxruntime-web$/ }, (args) =>
/[\\/]parakeet\.js[\\/]/.test(args.importer) ? { path: SHIM } : undefined,
);
},
};