فهرست منبع

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
Miguel Serrano 4 سال پیش
والد
کامیت
56d826f255
2فایلهای تغییر یافته به همراه7 افزوده شده و 1 حذف شده
  1. 2 1
      services/web/babel.config.json
  2. 5 0
      services/web/frontend/js/features/pdf-preview/util/pdf-js-wrapper.js

+ 2 - 1
services/web/babel.config.json

@@ -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 }
           }
         ]
       ]

+ 5 - 0
services/web/frontend/js/features/pdf-preview/util/pdf-js-wrapper.js

@@ -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')