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.
This commit is contained in:
Richard R 2026-06-04 21:54:32 -06:00
parent 2898e7e5cc
commit b594824a8f

View file

@ -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/**/*',
],