-
Notifications
You must be signed in to change notification settings - Fork 10k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to embed pdf.js into another module intended for use in webpack projects? #10324
Comments
I believe this is not an issue with nesting in the package, but instead with the See #10253. Unfortunately the only way to adjust this config currently is to eject from CRA. We have our own config where we turned this off. I wonder if PDFjs could support dynamic imports instead going forward as they are now a standard. |
Ah I see... Well, thanks @pk-nb! I did see some discussion over on the react repo for potentially adding web workers, but not sure if this ever panned out or would improve things for pdfjs and CRA users. |
So is it correct to say that you must eject from CRA in order for your project to use PDFJS? |
/cc @timvandermeij Given the example added in PR #11220, and that the |
Yes, indeed. |
I created a simple module for converting PDFs to image data URLs within React apps here:
https://github.com/marcaaron/react-pdf-to-image
If I import this into a webpack project e.g.
create-react-app
and then build / serve this project all goes well. But in development mode I receive the following error message in JS console.bootstrap:1 Uncaught ReferenceError: window is not defined
And webpack dev server complains about this:
./node_modules/pdfjs-dist/build/pdf.js Critical dependency: require function is used in a way in which dependencies cannot be statically extracted
Steps to reproduce the problem:
create-react-app
projectWhat is the expected behavior?
There would be some sort of way to add pdf.js with a worker as a dependency for other projects in development out of the box. Is this a limitation of web workers in general? Or can changes be made to the current distribution to allow this to work in all projects?
The text was updated successfully, but these errors were encountered: