web-infra-dev / rspack

The fast Rust-based web bundler with webpack-compatible API 🦀️
https://rspack.dev
MIT License
9.75k stars 561 forks source link

[Bug]: Getting "should have __webpack_require__.f.consumes" error with module federation enabled #7417

Open hverlin opened 3 months ago

hverlin commented 3 months ago

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.

dungnguyenBKA commented 2 months ago

I also faced this bug. My application have 1 worker and this bug occurred. When I comment out worker lines then app start working. Is that any update on how to fix that temporary @hverlin ?

hverlin commented 2 months ago

I did not find a way around this issue so far.

stale[bot] commented 5 days ago

This issue has been automatically marked as stale because it has not had recent activity. If this issue is still affecting you, please leave any comment (for example, "bump"). We are sorry that we haven't been able to prioritize it yet. If you have any new additional information, please include it with your comment!

hverlin commented 5 days ago

bump