Skip to content

'globalThis.pdfjsLib' undefined after upgrade to v.4.0.189 #17305

@pavdev64

Description

@pavdev64

Hi all,

I upgraded to pdfjs-dist 4.0.189 and changed *.js to *.mjs. The project compiles successfully, but I get this error in DevTools console:

pdf_viewer.mjs:3691 Uncaught (in promise) TypeError: Cannot destructure property 'AbortException' of 'globalThis.pdfjsLib' as it is undefined.
    at pdf_viewer.mjs:3691:1
    at ./node_modules/pdfjs-dist/legacy/web/pdf_viewer.mjs (pdf_viewer.mjs:11099:1)
    at __webpack_require__ (bootstrap:24:1)
    at fn (hot module replacement:62:1)
    at PdfReader.tsx:336:1
    at __webpack_require__.a (async module:49:1)
    at ./src/components/PdfReader/PdfViewer.tsx (PdfReader.tsx:336:1)
    at __webpack_require__ (bootstrap:24:1)
    at fn (hot module replacement:62:1)
    at src_components_PdfReader_PdfReader_tsx.chunk.js:25:68

The globalThis is window object but pdfjsLib is undefined.

Steps to reproduce the problem:

  1. upgrade to pdfjs-dist 4.0.189
  2. change
    pdfjs.GlobalWorkerOptions.workerSrc = 'static/scripts/pdf.worker.min.js';
    to
    pdfjs.GlobalWorkerOptions.workerSrc = 'static/scripts/pdf.worker.min.mjs';

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions