Attach (recommended) or Link to PDF file here: Not an issue while interacting with a pdf this is a webpack error when compiling
Configuration:
Steps to reproduce the problem:
import PDFJS from 'pdfjs-dist/webpack';
What is the expected behavior? Application compiles correctly
What went wrong? error occurs during build "Module not found: Error: Can't resolve 'worker-loader'"
It's entirely possible this is not how the pdfjs-dist was supposed to be used I ended up using that over just pdfjs since I needed it to work on IE and chrome sets up the worker for me without the dist package
What went wrong? error occurs during build "Module not found: Error: Can't resolve 'worker-loader'"
Did you actually install the worker-loader
package, since that needs to be done manually?
Does this example work, since it's not clear (to me at least) if you tried using it?
Finally, it's unlikely that anyone will be able to help without more context; hence please see https://github.com/mozilla/pdf.js/blob/master/.github/CONTRIBUTING.md (emphasis mine):
If you are developing a custom solution, first check the examples at https://github.com/mozilla/pdf.js#learning and search existing issues. If this does not help, please prepare a short well-documented example that demonstrates the problem and make it accessible online on your website, JS Bin, GitHub, etc. before opening a new issue or contacting us in the Matrix room -- keep in mind that just code snippets won't help us troubleshoot the problem.
We're been experiencing the same issue after the latest update!
In our production build we get a o is not a constructor
error on runtime.
We've tracked it down to pdfjs.GlobalWorkerOptions.workerPort = new PdfjsWorker();
in /pdfjs-dist/webpack.js
.
Currently importing pdfjs-dist classes such as getDocument crashes our app on runtime.
We've made sure worker-loader is installed.
Does anyone have a workaround?
We found our issue. We were using worker-loader 3.0.1 which is a new major version. Switching to 2.0.0 resolved our problem.
Most helpful comment
We found our issue. We were using worker-loader 3.0.1 which is a new major version. Switching to 2.0.0 resolved our problem.