From b594824a8f5ada9e638dd3f124dce15b8d95858c Mon Sep 17 00:00:00 2001 From: Richard R Date: Thu, 4 Jun 2026 21:54:32 -0600 Subject: [PATCH] chore(config): exclude pdfjs-dist from bundle and update asset tracing for standard fonts Add 'pdfjs-dist' to serverExternalPackages in Next.js config to prevent bundling, ensuring runtime resolution of on-disk assets like standard_fonts. Update tracing includes for API preview route to explicitly cover worker and font resources loaded dynamically. --- next.config.ts | 7 +++++++ 1 file changed, 7 insertions(+) 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/**/*', ],