fix(docker): polyfill DOMMatrix/ImageData/Path2D for pdfjs-dist in linux/amd64 container via NODE_OPTIONS --require

This commit is contained in:
Chandler Copeland
2026-04-03 18:02:39 -06:00
parent f15e538f5c
commit 2d2a43a3c9
5 changed files with 322 additions and 41 deletions

View File

@@ -0,0 +1,11 @@
// Polyfills for browser globals required by pdfjs-dist in Node.js.
// Required via NODE_OPTIONS=--require so it runs before any module evaluation.
if (typeof globalThis.DOMMatrix === 'undefined') {
globalThis.DOMMatrix = class DOMMatrix { constructor() { return this; } };
}
if (typeof globalThis.ImageData === 'undefined') {
globalThis.ImageData = class ImageData { constructor() { return this; } };
}
if (typeof globalThis.Path2D === 'undefined') {
globalThis.Path2D = class Path2D { constructor() { return this; } };
}