comlink icon indicating copy to clipboard operation
comlink copied to clipboard

Comlink setup with Webpack 5 & React

Open RonGootman opened this issue 4 years ago • 6 comments

Anyone can provide an example of comlink setup with webpack 5?

Webpack 5 supports work with web-workers natively therefore I used the following syntax to import my worker

const heavyCalc = new Worker(new URL('./heavyCalc.worker.js', import.meta.url));

That works absolutely fine on local environment.

Once a run a build on my React app and deploy it I get the following error 989.e091b9fb8db3edae7192.js:1 Uncaught TypeError: o.h is not a function

to be more precise: o.u = e=>443 === e ? "443.c16ce60f72c403c299d8.js" : e + ".bundle." + o.h() + ".js",

RonGootman avatar Oct 03 '21 17:10 RonGootman

Anyone can provide an example of comlink setup with webpack 5? @surma we are using this in a production mode, and comlink is the only blocker to switch to react18(webpack5), any suggestion ?

rubenaprikyan avatar May 10 '22 22:05 rubenaprikyan

Haven't had any specific problems with using webpack v5 and comlink, here's an example sandbox

benjamind avatar Jan 25 '23 19:01 benjamind

Will close this as invalid in the next couple of weeks unless someone can show a reproducible case different than the example sandbox above thats showing an issue.

benjamind avatar Jan 30 '23 22:01 benjamind

I was having issues with loading workers with comlink and Webpack 5. And ended up being a dumb issue with a dependency, i had correctly webpack on version 5.75.0, but I had webpack-cli, set to 4.9.2. When I upgraded webpack-cli to 5.0.1 all started to work fine again

GregorioF2 avatar Apr 11 '23 15:04 GregorioF2

Works fine during development but getting the below error in production build:

image

React v18 with react-scripts v5.0.1 and comlink-loader v2.0.0.

Some would be appreciated.

Waqqars987 avatar Mar 23 '24 15:03 Waqqars987

Works fine during development but getting the below error in production build:

image

React v18 with react-scripts v5.0.1 and comlink-loader v2.0.0.

Some would be appreciated.

Met the same issue in development.

react 18.2.0 webpack 5.91.0 comlink 4.3.1

But I didn't use comlink-loader.

chihiroxc avatar Apr 12 '24 02:04 chihiroxc