Skip to content

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

@RexSkz

Description

@RexSkz

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions