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

RegisterRemotes with override not working with Module Federation 2.0. #2436

Open
4 of 5 tasks
annfredin opened this issue May 2, 2024 · 5 comments
Open
4 of 5 tasks
Assignees
Labels
🐞 bug Something isn't working team

Comments

@annfredin
Copy link

annfredin commented May 2, 2024

Describe the bug

tools used:
Rsbuils, React, typescript, pnpm
refered react-manifest-example example.

registerRemotes(
[
{
name: "app1",
entry: http://localhost:3002/mf-manifest.json?v=${version},
},
],
{ force: true }
);

**When  updating registered remote wuth new version with force option, throwing the below error.**

react-dom.development.js:26951 Uncaught TypeError: Cannot delete property 'app1' of #<Window>
at FederationHost.removeRemote (index.cjs.js:1619:1)
at FederationHost.registerRemote (index.cjs.js:1664:1)
at index.cjs.js:1673:1
at Array.forEach (<anonymous>)
at FederationHost.registerRemotes (index.cjs.js:1672:1)
at registerRemotes (index.cjs.js:1783:1)
at RemotePage (remote-page.tsx:26:1)
at renderWithHooks (react-dom.development.js:15486:1)
at updateFunctionComponent (react-dom.development.js:19617:1)
at beginWork (react-dom.development.js:21640:1)

Reproduction

no reproduction

Used Package Manager

pnpm

System Info

Using RsBuild with below config.

import { defineConfig } from '@rsbuild/core';
import { pluginReact } from '@rsbuild/plugin-react';
import { ModuleFederationPlugin } from '@module-federation/enhanced/rspack';

export default defineConfig({
  server: {
    port: 3000,
  },
  tools: {
    rspack: (config, { appendPlugins }) => {
      appendPlugins([
        new ModuleFederationPlugin({
          name: 'hostapp',
          remotes: {
            remote1: 'remote1@http://localhost:3001/mf-manifest.json',
          },
          shared: ['react', 'react-dom'],
        }),
      ]);
    },
  },
  plugins: [pluginReact()],
});

Validations

@ScriptedAlchemy ScriptedAlchemy added 🐞 bug Something isn't working team labels May 2, 2024
@2heal1
Copy link
Member

2heal1 commented May 8, 2024

I can not reproduce the issue local , can you provide reproduction example ?

@annfredin
Copy link
Author

Please use the below repo
https://github.com/annfredin/mfe-manifest-example.

Usecase:
Once host app loaded the remote app, we may required to re-register/override the remote entry, when new version deployed(remote app). what is the way to update manifest URL.

In Host app remote1 page, i am trying to registerremote.

  1. got warning as [ Federation Runtime ]:The remote "remote1" is already registered. If you want to merge the remote, you can set "force: true".

  2. when register with force option, exception occured.
    Uncaught TypeError: Cannot delete property 'remote1' of #.

@ScriptedAlchemy
Copy link
Member

@2heal1 i was able to reproduce this issue in chrome.

@2heal1
Copy link
Member

2heal1 commented May 21, 2024

i fill fix it

@2heal1
Copy link
Member

2heal1 commented May 21, 2024

@annfredin I fix it , you can use @module-federation/enhanced@0.0.0-next-20240521035527 test whether the behavior matches your expectations

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐞 bug Something isn't working team
Projects
None yet
Development

No branches or pull requests

3 participants