Skip to content

perf(runtime-core): bypass range parsing in versionLt and cache satisfy ranges#4867

Draft
shashank-u03 wants to merge 2 commits into
module-federation:mainfrom
shashank-u03:perf/runtime-core-share-semver
Draft

perf(runtime-core): bypass range parsing in versionLt and cache satisfy ranges#4867
shashank-u03 wants to merge 2 commits into
module-federation:mainfrom
shashank-u03:perf/runtime-core-share-semver

Conversation

@shashank-u03

Copy link
Copy Markdown
Contributor

Description

Optimizes the share-resolution semver hot path in @module-federation/runtime-core without 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

  • 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

changeset-bot Bot commented Jul 2, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 101650d

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

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

netlify Bot commented Jul 2, 2026

Copy link
Copy Markdown

Deploy Preview for module-federation-docs ready!

Name Link
🔨 Latest commit 101650d
🔍 Latest deploy log https://app.netlify.com/projects/module-federation-docs/deploys/6a4664f513dfbb00080fff9f
😎 Deploy Preview https://deploy-preview-4867--module-federation-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

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

@shashank-u03
shashank-u03 marked this pull request as draft July 2, 2026 12:47

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

Copy link
Copy Markdown

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: 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".

Comment on lines 164 to 166
const bAtom = toCompareAtom(transformInvalidVersion(b));
if (!aAtom || !bAtom) {
return false;

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 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 👍 / 👎.

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