Skip to content

fix(enhanced): fix garbled version strings in build stats for shared modules#4622

Open
cascornelissen wants to merge 1 commit intomodule-federation:mainfrom
cascornelissen:fix/consume-shared-module-garbled-version-display
Open

fix(enhanced): fix garbled version strings in build stats for shared modules#4622
cascornelissen wants to merge 1 commit intomodule-federation:mainfrom
cascornelissen:fix/consume-shared-module-garbled-version-display

Conversation

@cascornelissen
Copy link
Copy Markdown

Description

Webpack build stats show garbled version strings for shared modules (e.g. !=6...3.0...3 instead of ^6.30.3). This happens because ConsumeSharedModule's display methods pass raw semver strings to rangeToString(), which expects parsed arrays.

This fix calls parseRange() on raw strings before passing them to rangeToString() in identifier() and readableIdentifier(), without changing runtime behavior.

Before:

consume shared module (default) react@!=1.6...1.4...0 (singleton)
consume shared module (default) react-router-dom@!=6...3.0...3 (singleton)

After:

consume shared module (default) react@^16.14.0 (singleton)
consume shared module (default) react-router-dom@^6.30.3 (singleton)

Related Issue

No existing issue. This bug was introduced in commit e7fada2 3 years ago, which removed parseRange() calls as a workaround for webpack#17756. That webpack bug has since been fixed in webpack 5.92.0 (June 2024, webpack#18459).

Types of changes

  • Docs change / refactoring / dependency upgrade
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)

Checklist

  • I have added tests to cover my changes.
  • All new and existing tests passed.
  • I have updated the documentation.

@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Apr 2, 2026

🦋 Changeset detected

Latest commit: f4af3f8

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 45 packages
Name Type
@module-federation/enhanced Patch
@module-federation/modern-js-v3 Patch
@module-federation/modern-js Patch
@module-federation/nextjs-mf Patch
@module-federation/node Patch
@module-federation/rsbuild-plugin Patch
@module-federation/rspress-plugin Patch
@module-federation/storybook-addon Patch
shared-tree-shaking-no-server-host Patch
shared-tree-shaking-no-server-provider Patch
shared-tree-shaking-with-server-host Patch
shared-tree-shaking-with-server-provider Patch
node-dynamic-remote-new-version Patch
node-dynamic-remote Patch
remote5 Patch
remote6 Patch
website-new Patch
@module-federation/runtime Patch
@module-federation/rspack Patch
@module-federation/webpack-bundler-runtime Patch
@module-federation/sdk Patch
@module-federation/runtime-tools Patch
@module-federation/managers Patch
@module-federation/manifest Patch
@module-federation/dts-plugin Patch
@module-federation/third-party-dts-extractor Patch
@module-federation/devtools Patch
@module-federation/bridge-react Patch
@module-federation/bridge-vue3 Patch
@module-federation/bridge-shared Patch
@module-federation/bridge-react-webpack-plugin Patch
@module-federation/retry-plugin Patch
@module-federation/data-prefetch Patch
@module-federation/error-codes Patch
@module-federation/inject-external-runtime-core-plugin Patch
@module-federation/runtime-core Patch
create-module-federation Patch
@module-federation/cli Patch
@module-federation/treeshake-server Patch
@module-federation/treeshake-frontend Patch
@module-federation/metro Patch
@module-federation/metro-plugin-rnef Patch
@module-federation/metro-plugin-rnc-cli Patch
@module-federation/esbuild Patch
@module-federation/utilities Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@netlify
Copy link
Copy Markdown

netlify bot commented Apr 2, 2026

Deploy Preview for module-federation-docs ready!

Name Link
🔨 Latest commit f4af3f8
🔍 Latest deploy log https://app.netlify.com/projects/module-federation-docs/deploys/69ce73ac1cdc6a0008aafa4b
😎 Deploy Preview https://deploy-preview-4622--module-federation-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@cascornelissen
Copy link
Copy Markdown
Author

cascornelissen commented Apr 2, 2026

As mentioned, this bug was introduced in commit e7fada2 3 years ago, that bug got fixed in webpack/webpack#18459 and released in webpack v5.92.0.

Open question: how should this be handled? I could introduce a check to use the old implementation based on the detected Webpack version, or do we introduce a minimum Webpack peer dependency version of v5.92.0, or something else?

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f4af3f87c3

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment on lines +102 to +104
typeof requiredVersion === 'string'
? parseRange(requiredVersion)
: requiredVersion,
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Guard parseRange before formatting requiredVersion

This call assumes webpack/lib/util/semver always provides parseRange, but the current unit harness for this module (packages/enhanced/test/unit/sharing/ConsumeSharedPlugin/ConsumeSharedModule.behavior.test.ts) mocks that dependency without parseRange. With a string requiredVersion (the default fixture), identifier() now throws TypeError: parseRange is not a function, so the sharing tests fail unless you add a fallback or update the mock in the same change.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant