rspack
rspack copied to clipboard
[Bug]: Getting "should have __webpack_require__.f.consumes" error with module federation enabled
System Info
Using 1.0.1-beta.9 (but visible on earlier versions as well).
Details
With module federation 1.5 (using https://rsbuild.dev/config/module-federation/options), I am getting the following error:
Uncaught Error: should have __webpack_require__.f.consumes
at __webpack_require__.f.consumes (_define_property.js:8:1)
at _define_property.js:8:1
at Array.reduce (<anonymous>)
at __webpack_require__.e (_define_property.js:8:1)
at Array.map (<anonymous>)
at __webpack_require__.x (_define_property.js:8:1)
at _define_property.js:8:1
at _define_property.js:8:1
(seems similar to https://github.com/web-infra-dev/rspack/issues/6773)
Reproduce Steps
I think this is related to web-workers. In my code, I think that it's failing because of this line.
import { wrap } from 'comlink';
...
const w = wrap(new Worker(new URL('workers/worker.js', import.meta.url)));
If I inline the web-worker in my code, the error goes away. This not a good workaround, however, as the performance of the application will suffer.