Replies: 1 comment
-
Hm, the "copying to public folder" is kind of a backup procedure if all else fails. Most bundlers will be able to leverage more convenient methods. Also, since the worker comes out of a secondary dependency, copying worker code as plain text would be a maintenance burden and would mean we will not be able to make React-PDF pdfjs version-agnostic ever. |
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.
-
Before you start - checklist
Description
The installation process for the web worker is a bit tedious and might be avoidable.
Proposed solution
I've got another project that utilizes a web worker. To avoid the issue around bundling and resolving the URL for the worker, I simply made it so that the worker is a string:
This way you can have the worker code wherever you want, import it as you normally would but then avoid the consumer of the package having to "make sure it goes in the public folder" and have them resolve the path and stuff.
Another alternative that works with the node
web-worker
package is literally encoding the whole worker in the url:Could this be a possible option for this package as well? Or are there some issues that I have not foreseen yet? Maybe the size of your worker file could make this less ideal?
Alternatives
No response
Additional information
No response
Beta Was this translation helpful? Give feedback.
All reactions