24 lines
871 B
TypeScript
24 lines
871 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-051). 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,
|
|
);
|
|
},
|
|
};
|