Replies: 1 comment
-
This needs to be fixed in your bundler configuration. The worker needs to be listed as an entry point. Your workaround is wrong, because its loading the worker code in the main thread |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
When building in nodejs environment (nuxt server) I get the error
Setting up fake worker failed: "Cannot find module .../node_modules/pdf/dist/build/pdf.worker.mjs' imported...
This seems due to treeshaking in nuxt (rollup).
The fix would be to import the worker and log it so it's kept in the treeshaked bundle.
Is there any better solution? Can this be fixed in the package itself?
Web browser and its version
nodejs
Operating system and its version
node 22
PDF.js version
[email protected]
Is the bug present in the latest PDF.js version?
Yes
Is a browser extension
No
Steps to reproduce the problem
Use latest pdfjs-dist in combination with rollupjs
What is the expected behavior?
It should work as in the examples:
https://github.com/mozilla/pdf.js/tree/master/examples/node
What went wrong?
Cannot find module .../node_modules/pdf/dist/build/pdf.worker.mjs' imported...
Link to a viewer
No response
Additional context
No response
Beta Was this translation helpful? Give feedback.
All reactions