fix(enhanced): fix garbled version strings in build stats for shared modules#4622
Conversation
🦋 Changeset detectedLatest commit: f4af3f8 The changes in this PR will be included in the next version bump. This PR includes changesets to release 45 packages
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 |
✅ Deploy Preview for module-federation-docs ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
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? |
There was a problem hiding this comment.
💡 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".
| typeof requiredVersion === 'string' | ||
| ? parseRange(requiredVersion) | ||
| : requiredVersion, |
There was a problem hiding this comment.
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 👍 / 👎.
Description
Webpack build stats show garbled version strings for shared modules (e.g.
!=6...3.0...3instead of^6.30.3). This happens becauseConsumeSharedModule's display methods pass raw semver strings torangeToString(), which expects parsed arrays.This fix calls
parseRange()on raw strings before passing them torangeToString()inidentifier()andreadableIdentifier(), without changing runtime behavior.Before:
After:
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
Checklist