fix pdf.js worker dual-instance when uploading via evidence-source.
All checks were successful
CI Smoke / host-smoke (push) Successful in 0s
CI Smoke / container-smoke (push) Successful in 2s

Alias and dedupe pdfjs-dist so GlobalWorkerOptions.workerSrc set in main.tsx
reaches getDocument in the linked evidence-source package; allow sibling fs roots.
This commit is contained in:
tegwick 2026-07-30 19:33:19 +02:00
parent 6bc1650285
commit dc7d8f7ce8

View file

@ -37,14 +37,26 @@ export default defineConfig({
"@binder": resolve(__dirname, "../evidence-binder/src"),
"@work": resolve(__dirname, "../citation-work/src/work"),
"@app": resolve(__dirname, "src/app"),
// Force a single pdfjs-dist instance across the umbrella and linked
// packages (evidence-source, citation-work, …). Each sibling has its
// own node_modules/pdfjs-dist path; without this alias Vite loads two
// module graphs, so main.tsx's GlobalWorkerOptions.workerSrc never
// reaches getDocument() inside evidence-source — upload fails with
// 'No "GlobalWorkerOptions.workerSrc" specified.'
"pdfjs-dist": resolve(__dirname, "node_modules/pdfjs-dist"),
},
// Belt-and-braces for the same dual-instance problem (React too).
dedupe: ["pdfjs-dist", "react", "react-dom"],
},
server: {
fs: {
// Allow Vite to serve /fixtures/pdfs/*.pdf from the project root.
// Allow Vite to serve /fixtures/pdfs/*.pdf from the project root,
// and to read linked sibling packages outside this repo root.
allow: [
resolve(__dirname),
resolve(__dirname, "../citation-engine"),
resolve(__dirname, "../evidence-source"),
resolve(__dirname, "../evidence-anchor"),
resolve(__dirname, "../evidence-binder"),
resolve(__dirname, "../citation-work"),
],