Closed polisen closed 2 years ago
I haven't seen the comlink-loader
used before for workers. Reading their issues list, there's a couple of potential issues that may help.
Webpack 5 compatibility: the project hasn't been updated since Jan 2020, and there is an open issue for changes required to make it compatible with Webpack 5. For them it was complaining about __webpack_exports__
rather than the require, so their solution might not help you but it still would be worth looking at. There is one option people were able to set to get it working:
https://github.com/GoogleChromeLabs/comlink-loader/issues/34
Another person found that the singleton mode wouldn't work without adding a babel loader portion to the use
array as well. If the Webpack 5 issue's option doesn't help, the addition of babel-loader to the list of use
loaders for the worker might:
https://github.com/GoogleChromeLabs/comlink-loader/issues/36
Failing those, are you able to provide an example repository that has this issue so that I can trace through what is happening during compilation?
FWIW: I had a similar problem. Two issues in my case:
config.module.rules.unshift(...)
), while addWebpackModuleRule
adds it to the oneOf
entry, see https://github.com/arackaf/customize-cra/blob/master/src/customizers/webpack.js#327.Closing this given no recent activity.
Hey - I'm using customize-cra and react-app-rewired to override the webpack config usually abstracted away in a create-react-app.
I'm importing the random-int package to the worker file - which is the import that fails.
config-overrides.js
This is the correct syntax - but now it complains about that webpack doesn't have a require function - which is to be expected. Supposedly something wasn't transpiled by babel but I can't figure out where to even begin.
Do you geniuses have any idea?