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

Module federation: the usage of "dynamic remotes" will cause blank screen when working with runtimeChunk #18361

Open
RexSkz opened this issue Apr 27, 2024 · 0 comments

Comments

@RexSkz
Copy link

RexSkz commented Apr 27, 2024

Bug report

What is the current behavior?

If I set optimization.runtimeChunk and use dynamic remotes, the app will show a blank screen with no error.

const remotes = {
  app1: `promise new Promise(resolve => {
    // ...
    resolve({
      get: (request) => window.app1.get(request),
      init: (arg) => {
        try { return window.app1.init(arg) } catch { }
      }
    })
    // ...
  }
}

If the current behavior is a bug, please provide the steps to reproduce.

  1. Clone the repo: https://github.com/RexSkz/mf-dynamic-remotes-circular-reference
  2. Run pnpm i && pnpm start (it's a monorepo which uses pnpm workspace feature)
  3. Open http://localhost:3000 in your browser

There is more information (also with my investigation) in this repo.

What is the expected behavior?

You will get a console trace (with the number 42) immediately after the page is loaded.

image

Either removeing optimization.runtimeChunk or using hard-coded remotes instead of dynamic remotes will solve the issue. But to fully solve it, we should pass ...args instead of arg in init.

I'm not sure whether it's a documentation issue or some sort of design, please correct me if anything wrong :)

Other relevant information:
webpack version: 5.91.0
Node.js version: 18.19.0
Operating System: Windows 11
Additional tools: none

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

1 participant