Skip to content

Module Federation Fails to Share Singleton Dependencies with Version Postfixes (e.g., -release.99) #4078

@KappyJS

Description

@KappyJS

Describe the bug

We are using Module Federation in a monorepo setup with rslib and rsbuild. We are successfully sharing and consuming modules in a shared scope. However, we have encountered a critical issue with sharing singleton dependencies when their version numbers contain a postfix (e.g., 2.2.2-release.99).

When a shared library has a version with a postfix, Module Federation does not treat it as a shared singleton. Instead, each remote application loads its own separate instance of the dependency, defeating the purpose of sharing and potentially causing runtime errors (e.g., multiple instances of React, broken context providers).

This behavior is inconsistent. If we remove the postfix and use a standard semantic version (e.g., 2.2.2), the sharing mechanism works perfectly as expected.

Shared

// Remote config (sharing the module)
shared: {
  'my-shared-library': {
    singleton: true,
    requiredVersion: '2.2.2-release.99', // Version with postfix
  },
},

Consume

shared: {
  'my-shared-library': {
    requiredVersion: '*', // Willing to accept any version
  },
},

Reproduction

Share module: requiredVersion: '2.2.2-release.99', // Version with postfix, Consume: requiredVersion: '*',

Used Package Manager

pnpm

System Info

System:
    OS: macOS 15.6.1
    CPU: (12) arm64 Apple M3 Pro
    Memory: 111.97 MB / 18.00 GB
    Shell: 3.2.57 - /bin/bash
  Binaries:
    Node: 18.20.7 - ~/.nvm/versions/node/v18.20.7/bin/node
    npm: 10.8.2 - ~/.nvm/versions/node/v18.20.7/bin/npm
  Browsers:
    Chrome: 139.0.7258.128
    Safari: 18.6

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