wojtekmaj / react-pdf

Display PDFs in your React app as easily as if they were images.
https://projects.wojtekmaj.pl/react-pdf
MIT License
9.47k stars 886 forks source link

Can't find variable: on #1844

Open ildar945k opened 3 months ago

ildar945k commented 3 months ago

Before you start - checklist

Description

Some users are getting error trying to preview pdf:

Can't find variable: on

` at webpack:///node_modules/pdfjs-dist/build/pdf.mjs. line: 15417. column: 38. name: at webpack:///node_modules/pdfjs- dist/build/pdf.mjs. line: 18573. column: 0. name: at webpack:///webpack/bootstrap. line: 19. column: 36. name: module at webpack:///node_modules/react-pdf/dist/cjs/index.js

`

"react-pdf": "9.0.0", "pdfjs-dist": "4.3.136", "webpack": "5.90.3", "react": "18.2.0",

      if (typeof Promise.withResolvers === "undefined") {
               if (window) {     
                    window.Promise.withResolvers = function() {
                      let resolve, reject;
                      const promise = new Promise((res, rej) => {
                        resolve = res;
                        reject = rej;
                      });
                      return { promise, resolve, reject };
                    };
              }
      }

    pdfjs.GlobalWorkerOptions.workerSrc = new URL(
      "pdfjs-dist/legacy/build/pdf.worker.min.mjs",
      import.meta.url
    ).toString();

``

Steps to reproduce

No way to repro

Expected behavior

No error

Actual behavior

Error

Additional information

Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.3 Safari/605.1.15

Environment

github-actions[bot] commented 2 weeks ago

This issue is stale because it has been open 90 days with no activity. Remove stale label or comment or this issue will be closed in 14 days.