Skip to content

upgrading to wp5 beta 20 breaks the application due to change in Module Federation remote logic (Overrides fail) #2

@tsukhu

Description

@tsukhu

Hi @jherr ,

I really liked this approach where you can dynamically load Module Federation WP5 components into an existing app that currently is using the older version of webpack . But looks like that the internal implementation of Module Federation has changed, due to which the overrides logic does not work anymore and we get this error in the dashboard app

TypeError: window[scope].override is not a function
RemoteReactComponent
C:/workspace/tkdash/wp5-dashboard/dashboard/src/App.js:52
  49 | 
  50 |  if (ready) {
  51 |    const o = global.__webpack_require__ ? global.__webpack_require__.o : {};
> 52 |    window[scope].override(
     | ^  53 |      Object.assign(
  54 |        {
  55 |          recoil: () => Promise.resolve().then(() => () => require("recoil")),

I tried to look at the new remotes that are generated but was not able to figure this one out. It would be great if you can shed some light on this as the mode of dynamically loading Module federation remotes was a great idea 💡

To demonstrate this I have forked your project and upgraded the webpack version to the latest version. Also made some minor tweaks to make it work on a Windows machine :-)

Here is the repo to reproduce the issue
https://github.com/tsukhu/wp5-dashboard

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions