How do I import a library like jimp
or moment
in a Web worker?
I tried to follow the answers given here How to import a library like moment.js into a web worker, but they did not work:
With the entry point, the bundle file was never produced and I couldn't use the web worker.
With the web-worker
, it says Attempted import error:
'./myWorker.worker.js' does not contain a default export (imported as 'Worker').
I also tried the solution given here:
Web Workers - How To Import Modules
I was able to access the WebWorker and get it to post a message (unlike in the above solutions), but as soon as I add import
statements, it just gives an error like this:
How can I fix this?