Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Unable to build a web worker module federation consumer #3530

Open
5 tasks done
yf-yang opened this issue Feb 19, 2025 · 1 comment
Open
5 tasks done

[Bug]: Unable to build a web worker module federation consumer #3530

yf-yang opened this issue Feb 19, 2025 · 1 comment

Comments

@yf-yang
Copy link

yf-yang commented Feb 19, 2025

Describe the bug

I've checked web worker related issues and seems this one is different?

Generally I want to achieve the following:
Suppose there is a lib (packages/dep) which exports a function createWorker, it spawns a web worker (not service worker) and the worker should be able to load content from remote module federation provider.

The createWorker function is imported by a web app and used there.

Now the problem:

  1. rslib can build, but the createWorker function cannot work. The error log is:
 [ Federation Runtime ]: [ Federation Runtime ]: The attribute remoteEntry of mf_remote must not be undefined.

However, the actual problem is that module federation runtime has a function called getRemoteEntryInfoFromSnapshot

Image

Neither if branch is matched so it falls back to no url.
I'd like to know how to deal with this case.

  1. If dep package is not built, then with rspack source build enabled, loadRemote also fails with the same error.

Reproduction

https://github.com/yf-yang/modernjs-monorepo-example

pnpm i
pnpm build:deps
pnpm dev

Then open localhost:8080 and click "Create worker from dep", it should call loadRemote from within a worker

Used Package Manager

pnpm

System Info

System:
    OS: macOS 13.2.1
    CPU: (16) x64 Intel(R) Core(TM) i9-9980HK CPU @ 2.40GHz
    Memory: 77.39 MB / 32.00 GB
    Shell: 5.8.1 - /bin/zsh
  Browsers:
    Chrome: 133.0.6943.98
    Safari: 16.3
  npmPackages:
    @rslib/core: 0.5.0-alpha.0 => 0.5.0-alpha.0

Validations

@ScriptedAlchemy
Copy link
Member

This is likely a problem with how federation runtime is applied to this target, i think i fixed this in webpack v1 - however there may be some additiional work for v2.

#3453 most likely blocks the implementation

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants