Force Promise.allSettled polyfill (#6192)

* Force `Promise.allSettled` polyfill

`Promise.allSettled` is required by `pdf.js`, but the polyfill is not available in the bundle. This forces babel to include the polyfill without having to process `pdf.js` with webpack/babel, which causes issues loading documents.

* Updated core.js version for test config

GitOrigin-RevId: 981da187352ffc8c59cb77ba55a0a9643bd7cc9a
This commit is contained in:
Miguel Serrano 2022-01-11 18:20:03 +01:00 committed by Copybot
parent 35396ab61a
commit 56d826f255
2 changed files with 7 additions and 1 deletions

View file

@ -32,7 +32,8 @@
{
"targets": { "node": "12.21" },
"useBuiltIns": "usage",
"corejs": { "version": 3 }
// This version must be aligned with the `core-js` version in `package.json`
"corejs": { "version": 3.6 }
}
]
]

View file

@ -11,6 +11,11 @@ if (typeof window !== 'undefined' && 'Worker' in window) {
PDFJS.GlobalWorkerOptions.workerPort = new PDFJSWorker()
}
// forces the method (required by pdf.js) to be polyfilled by webpack, since
// processing pdf.js by webpack/babel causes issues loading documents
// eslint-disable-next-line no-unused-expressions
Promise.allSettled
const params = new URLSearchParams(window.location.search)
const disableFontFace = params.get('disable-font-face') === 'true'
const cMapUrl = getMeta('ol-pdfCMapsPath')