Skip to content

shared configuration not fully reflected in mf-manifest.json (enhanced federation with Rsbuild) #3101

@foxylion

Description

@foxylion

Describe the bug

I tried configuring the shared section of the module federation configuration, but some changes are not being reflected in the mf-manifest.json file.

Steps to Reproduce:

  • Clone the repository from here.
  • Start the project located at rsbuild/module-federation-enhanced/consumer, the configuration includes the following:
     shared: {
       react: { singleton: false, requiredVersion: '^18.0.0' },
       'react-dom': { singleton: false, requiredVersion: '^18.0.0' },
     }
  • Check the mf-manifest.json file at http://localhost:2000/mf-manifest.json, the shared block in the manifest contains the following:
     "shared": [
       {
         "id": "federation_consumer:react-dom",
         "name": "react-dom",
         "version": "18.2.0",
         "singleton": true,
         "requiredVersion": "^18.2.0",
         "assets": {
           "js": {
             "async": [
               "static/js/async/vendors-node_modules_pnpm_react_18_2_0_node_modules_react_index_js.js"
             ],
             "sync": [
               "static/js/async/vendors-node_modules_pnpm_react-dom_18_2_0_react_18_2_0_node_modules_react-dom_index_js.js"
             ]
           },
           "css": {
             "async": [],
             "sync": []
           }
         }
       },
       {
         "id": "federation_consumer:react",
         "name": "react",
         "version": "18.2.0",
         "singleton": true,
         "requiredVersion": "^18.2.0",
         "assets": {
           "js": {
             "async": [],
             "sync": [
               "static/js/async/vendors-node_modules_pnpm_react_18_2_0_node_modules_react_index_js.js"
             ]
           },
           "css": {
             "async": [],
             "sync": []
           }
         }
       }
     ]

The mf-manifest.json file reflects the singleton setting as true, despite my configuration setting it to false. Additionally, the requiredVersion specified in my configuration (^18.0.0) seems to be overridden by default values.

Reproduction

https://github.com/foxylion/rspack-examples/tree/repro/share-config-not-in-mf-manifest-json (Diff)

Used Package Manager

pnpm

System Info

System:
  OS: Linux 6.8 Ubuntu 24.04.1 LTS 24.04.1 LTS (Noble Numbat)
  CPU: (20) x64 12th Gen Intel(R) Core(TM) i7-12700H
  Memory: 4.60 GB / 31.02 GB
  Container: Yes
  Shell: 5.9 - /bin/zsh
Binaries:
  Node: 20.18.0 - ~/.nvm/versions/node/v20.18.0/bin/node
  npm: 10.8.2 - ~/.nvm/versions/node/v20.18.0/bin/npm
  pnpm: 9.12.1 - ~/.local/share/pnpm/pnpm
Browsers:
  Chrome: 129.0.6668.100

Validations

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