perf(runtime-core): bypass range parsing in versionLt and cache satisfy ranges#4867
perf(runtime-core): bypass range parsing in versionLt and cache satisfy ranges#4867shashank-u03 wants to merge 2 commits into
Conversation
🦋 Changeset detectedLatest commit: 101650d The changes in this PR will be included in the next version bump. This PR includes changesets to release 47 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. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e925c6e7d1
ℹ️ 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".
| const bAtom = toCompareAtom(transformInvalidVersion(b)); | ||
| if (!aAtom || !bAtom) { | ||
| return false; |
There was a problem hiding this comment.
Preserve wildcard versions when comparing shares
When a registered share version is a wildcard or x-range such as *, x, or 1.x, toCompareAtom(transformInvalidVersion(b)) returns null, so versionLt now returns false. The previous implementation delegated to satisfy(a, '<=' + b), which normalized those ranges and returned true for matching versions; for example, findVersion({ '1.0.0': ..., '*': ... }) used to select the wildcard entry but now keeps 1.0.0. If existing configs/manifests rely on those accepted wildcard version strings, share resolution can pick a different provider after this optimization.
Useful? React with 👍 / 👎.
Description
Optimizes the share-resolution semver hot path in
@module-federation/runtime-corewithout changing public API or behavior.versionLt (used by findVersion on every loadShare / loadShareSync) previously implemented a <= b via satisfy(a, '<=' + b), running the full range parser for a simple point comparison. satisfy(versionKey, requiredVersion) in getRegisteredShare also re-parsed the same requiredVersion on every loop iteration.
This PR rewrites versionLt to use toCompareAtom() + compare() directly, extracts shared semver helpers in semver/index.ts, and caches parsed range comparators in satisfy(). Adds versionLt.spec.ts for parity and findVersion coverage, plus a patch changeset.
Related Issue
N/A
Types of changes
Checklist