diff --git a/next.config.ts b/next.config.ts index 2607972..1e2f4b7 100644 --- a/next.config.ts +++ b/next.config.ts @@ -20,6 +20,10 @@ const serverExternalPackages = [ '@napi-rs/canvas', 'better-sqlite3', 'ffmpeg-static', + // Keep pdfjs-dist out of the bundle: it resolves its own on-disk assets + // (standard_fonts) at runtime via require.resolve, which only works if it + // stays a real package in node_modules rather than being inlined. + 'pdfjs-dist', ...(!bundleWorkerCompute ? ['onnxruntime-node', '@huggingface/tokenizers'] : []), ]; @@ -52,6 +56,9 @@ const nextConfig: NextConfig = { './node_modules/ffmpeg-static/ffmpeg', ], '/api/documents/blob/preview/ensure': [ + // standard_fonts + the worker are loaded by path/specifier, not a static + // import, so trace them explicitly. The rest of pdfjs-dist is pulled in + // automatically now that it is a server-external package. './node_modules/pdfjs-dist/legacy/build/pdf.worker.mjs', './node_modules/pdfjs-dist/standard_fonts/**/*', ],