fix: replace pdf-parse with direct pdfjs-dist to fix DOMMatrix error in production
All checks were successful
Deploy to VPS / deploy (push) Successful in 1m10s
All checks were successful
Deploy to VPS / deploy (push) Successful in 1m10s
pdf-parse v2 depends on @napi-rs/canvas (native module) which fails in Next.js standalone Docker builds — native binaries aren't traced/copied to the standalone output, causing DOMMatrix is not defined at runtime. Replaced pdf-parse entirely with pdfjs-dist legacy build which works natively in Node.js without canvas or DOM API dependencies: - New src/lib/pdf.ts: extractTextFromPdf() using pdfjs-dist/legacy/build - Worker file explicitly imported so Next.js file tracer includes it - Updated all call sites: documents, norms/parse, contracts - Removed pdf-parse from dependencies, added pdfjs-dist directly - Changed serverExternalPackages from pdf-parse to pdfjs-dist Verified: build succeeds, both pdf.mjs and pdf.worker.mjs present in .next/standalone, text extraction works in standalone context. Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
23
package-lock.json
generated
23
package-lock.json
generated
@@ -17,7 +17,7 @@
|
||||
"mammoth": "^1.12.0",
|
||||
"next": "16.2.3",
|
||||
"next-auth": "^4.24.13",
|
||||
"pdf-parse": "^2.4.5",
|
||||
"pdfjs-dist": "^5.4.296",
|
||||
"pg": "^8.20.0",
|
||||
"react": "19.2.4",
|
||||
"react-dom": "19.2.4"
|
||||
@@ -2058,6 +2058,7 @@
|
||||
"resolved": "https://registry.npmjs.org/@napi-rs/canvas/-/canvas-0.1.80.tgz",
|
||||
"integrity": "sha512-DxuT1ClnIPts1kQx8FBmkk4BQDTfI5kIzywAaMjQSXfNnra5UFU9PwurXrl+Je3bJ6BGsp/zmshVVFbCmyI+ww==",
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"workspaces": [
|
||||
"e2e/*"
|
||||
],
|
||||
@@ -7148,26 +7149,6 @@
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/pdf-parse": {
|
||||
"version": "2.4.5",
|
||||
"resolved": "https://registry.npmjs.org/pdf-parse/-/pdf-parse-2.4.5.tgz",
|
||||
"integrity": "sha512-mHU89HGh7v+4u2ubfnevJ03lmPgQ5WU4CxAVmTSh/sxVTEDYd1er/dKS/A6vg77NX47KTEoihq8jZBLr8Cxuwg==",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"@napi-rs/canvas": "0.1.80",
|
||||
"pdfjs-dist": "5.4.296"
|
||||
},
|
||||
"bin": {
|
||||
"pdf-parse": "bin/cli.mjs"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=20.16.0 <21 || >=22.3.0"
|
||||
},
|
||||
"funding": {
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/mehmet-kozan"
|
||||
}
|
||||
},
|
||||
"node_modules/pdfjs-dist": {
|
||||
"version": "5.4.296",
|
||||
"resolved": "https://registry.npmjs.org/pdfjs-dist/-/pdfjs-dist-5.4.296.tgz",
|
||||
|
||||
Reference in New Issue
Block a user