You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm currently having issues with pdfjs-dist latest version (4.8.69). In our webapp (react-ts-webpack) we already have an old version of the lib (2.6.347).
As we compile ES5 code for legacy requirements, I needed to first parse the files with babel, to be able to import them.
Now my main issue is about the worker setup. I tried different approaches:
Import webpack.mjs from the build/ folder as stated in the WIKI.
Build correctly, error in the console import.meta.url can't be used outside module
Use our current implementation:
import * as pdfjs from 'pdfjs-dist';
import PdfjsWorker = require('worker-loader!pdfjs-dist/build/pdf.worker.js');
if (typeof window !== 'undefined' && 'Worker' in window) {
pdfjs.GlobalWorkerOptions.workerPort = new PdfjsWorker();
}
But with the new files:
import * as pdfjs from 'pdfjs-dist/build/pdf.mjs';
import PDFWorker = require('worker-loader!pdfjs-dist/build/pdf.worker.mjs');
Build correctly too, but in the console it throws an error about importing an ESM module in a .cjs file
Same as above, but import the worker from the legacy folder:
import * as pdfjs from 'pdfjs-dist/legacy/pdf.mjs';
import PDFWorker = require('worker-loader!pdfjs-dist/legacy/pdf.worker.mjs');
Error in the console about __webpack_require__ being an empty object (error is: could not call property .d of undefined, reading __webpack_require__.d())
Does someone had similar issues? Thanks in advance
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I'm currently having issues with pdfjs-dist latest version (4.8.69). In our webapp (react-ts-webpack) we already have an old version of the lib (2.6.347).
As we compile ES5 code for legacy requirements, I needed to first parse the files with babel, to be able to import them.
Now my main issue is about the worker setup. I tried different approaches:
Import
webpack.mjs
from thebuild/
folder as stated in the WIKI.Build correctly, error in the console import.meta.url can't be used outside module
But with the new files:
Build correctly too, but in the console it throws an error about importing an ESM module in a .cjs file
Error in the console about
__webpack_require__
being an empty object (error is:could not call property .d of undefined, reading __webpack_require__.d()
)Does someone had similar issues? Thanks in advance
Beta Was this translation helpful? Give feedback.
All reactions