18 lines
660 B
TypeScript
18 lines
660 B
TypeScript
|
|
/**
|
||
|
|
* Vitest setup: point PDF.js at its legacy worker bundle for Node runs.
|
||
|
|
*
|
||
|
|
* `extractPdf` deliberately does no worker setup (so the same module loads in
|
||
|
|
* browsers and Node). In Node tests we configure `GlobalWorkerOptions.workerSrc`
|
||
|
|
* here, once per test file, before any extraction runs. The legacy bundle ships
|
||
|
|
* as plain JS and works through PDF.js's fake-worker fallback when no real
|
||
|
|
* Worker is available.
|
||
|
|
*/
|
||
|
|
|
||
|
|
import { createRequire } from "node:module";
|
||
|
|
import * as pdfjs from "pdfjs-dist";
|
||
|
|
|
||
|
|
const require = createRequire(import.meta.url);
|
||
|
|
pdfjs.GlobalWorkerOptions.workerSrc = require.resolve(
|
||
|
|
"pdfjs-dist/legacy/build/pdf.worker.mjs",
|
||
|
|
);
|