Skip to content

feat(runtime): support getInstance finder callback#4703

Merged
2heal1 merged 3 commits into
module-federation:mainfrom
2heal1:feat/get-instance-find
May 6, 2026
Merged

feat(runtime): support getInstance finder callback#4703
2heal1 merged 3 commits into
module-federation:mainfrom
2heal1:feat/get-instance-find

Conversation

@2heal1
Copy link
Copy Markdown
Member

@2heal1 2heal1 commented May 6, 2026

Description

This PR adds a callback finder for the getInstance method. This allows users to find instances using a callback function, providing more flexibility in instance retrieval.

Key changes:

  • Implemented callback finder in getInstance.
  • Added comprehensive unit tests for the new functionality.
  • Updated documentation in both English and Chinese.
  • Included changeset for versioning.

Related Issue

Related to #4702

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 May 6, 2026

🦋 Changeset detected

Latest commit: 479d474

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

Deploy Preview for module-federation-docs ready!

Name Link
🔨 Latest commit 479d474
🔍 Latest deploy log https://app.netlify.com/projects/module-federation-docs/deploys/69fb03dcad36b60008d5b93b
😎 Deploy Preview https://deploy-preview-4703--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.

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: 43c72eabf6

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

remotes: [],
});

expect(getInstance()).toBe(defaultInstance);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Reset singleton state before asserting the default instance

This expectation depends on init() having just made defaultInstance the default, but earlier tests in the same describe already call init() and leave the module-level FederationInstance set; subsequent init() calls with different names create new registered instances without replacing that singleton. In the normal sequential Vitest run for api.spec.ts, getInstance() will still return the first instance created near the top of the file, so this newly added test fails unless the runtime globals/module state are reset or the assertion accounts for the existing singleton.

Useful? React with 👍 / 👎.

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented May 6, 2026

Open in StackBlitz

@module-federation/devtools

pnpm add https://pkg.pr.new/module-federation/core/@module-federation/devtools@ea46ccf

@module-federation/cli

pnpm add https://pkg.pr.new/module-federation/core/@module-federation/cli@ea46ccf

create-module-federation

pnpm add https://pkg.pr.new/module-federation/core/create-module-federation@ea46ccf

@module-federation/dts-plugin

pnpm add https://pkg.pr.new/module-federation/core/@module-federation/dts-plugin@ea46ccf

@module-federation/enhanced

pnpm add https://pkg.pr.new/module-federation/core/@module-federation/enhanced@ea46ccf

@module-federation/error-codes

pnpm add https://pkg.pr.new/module-federation/core/@module-federation/error-codes@ea46ccf

@module-federation/esbuild

pnpm add https://pkg.pr.new/module-federation/core/@module-federation/esbuild@ea46ccf

@module-federation/managers

pnpm add https://pkg.pr.new/module-federation/core/@module-federation/managers@ea46ccf

@module-federation/manifest

pnpm add https://pkg.pr.new/module-federation/core/@module-federation/manifest@ea46ccf

@module-federation/metro

pnpm add https://pkg.pr.new/module-federation/core/@module-federation/metro@ea46ccf

@module-federation/metro-plugin-rnc-cli

pnpm add https://pkg.pr.new/module-federation/core/@module-federation/metro-plugin-rnc-cli@ea46ccf

@module-federation/metro-plugin-rnef

pnpm add https://pkg.pr.new/module-federation/core/@module-federation/metro-plugin-rnef@ea46ccf

@module-federation/metro-plugin-rock

pnpm add https://pkg.pr.new/module-federation/core/@module-federation/metro-plugin-rock@ea46ccf

@module-federation/modern-js

pnpm add https://pkg.pr.new/module-federation/core/@module-federation/modern-js@ea46ccf

@module-federation/modern-js-v3

pnpm add https://pkg.pr.new/module-federation/core/@module-federation/modern-js-v3@ea46ccf

@module-federation/native-federation-tests

pnpm add https://pkg.pr.new/module-federation/core/@module-federation/native-federation-tests@ea46ccf

@module-federation/native-federation-typescript

pnpm add https://pkg.pr.new/module-federation/core/@module-federation/native-federation-typescript@ea46ccf

@module-federation/nextjs-mf

pnpm add https://pkg.pr.new/module-federation/core/@module-federation/nextjs-mf@ea46ccf

@module-federation/node

pnpm add https://pkg.pr.new/module-federation/core/@module-federation/node@ea46ccf

@module-federation/retry-plugin

pnpm add https://pkg.pr.new/module-federation/core/@module-federation/retry-plugin@ea46ccf

@module-federation/rsbuild-plugin

pnpm add https://pkg.pr.new/module-federation/core/@module-federation/rsbuild-plugin@ea46ccf

@module-federation/rspack

pnpm add https://pkg.pr.new/module-federation/core/@module-federation/rspack@ea46ccf

@module-federation/rspress-plugin

pnpm add https://pkg.pr.new/module-federation/core/@module-federation/rspress-plugin@ea46ccf

@module-federation/runtime

pnpm add https://pkg.pr.new/module-federation/core/@module-federation/runtime@ea46ccf

@module-federation/runtime-core

pnpm add https://pkg.pr.new/module-federation/core/@module-federation/runtime-core@ea46ccf

@module-federation/runtime-tools

pnpm add https://pkg.pr.new/module-federation/core/@module-federation/runtime-tools@ea46ccf

@module-federation/sdk

pnpm add https://pkg.pr.new/module-federation/core/@module-federation/sdk@ea46ccf

@module-federation/storybook-addon

pnpm add https://pkg.pr.new/module-federation/core/@module-federation/storybook-addon@ea46ccf

@module-federation/third-party-dts-extractor

pnpm add https://pkg.pr.new/module-federation/core/@module-federation/third-party-dts-extractor@ea46ccf

@module-federation/treeshake-frontend

pnpm add https://pkg.pr.new/module-federation/core/@module-federation/treeshake-frontend@ea46ccf

@module-federation/treeshake-server

pnpm add https://pkg.pr.new/module-federation/core/@module-federation/treeshake-server@ea46ccf

@module-federation/typescript

pnpm add https://pkg.pr.new/module-federation/core/@module-federation/typescript@ea46ccf

@module-federation/utilities

pnpm add https://pkg.pr.new/module-federation/core/@module-federation/utilities@ea46ccf

@module-federation/webpack-bundler-runtime

pnpm add https://pkg.pr.new/module-federation/core/@module-federation/webpack-bundler-runtime@ea46ccf

@module-federation/bridge-react

pnpm add https://pkg.pr.new/module-federation/core/@module-federation/bridge-react@ea46ccf

@module-federation/bridge-react-webpack-plugin

pnpm add https://pkg.pr.new/module-federation/core/@module-federation/bridge-react-webpack-plugin@ea46ccf

@module-federation/bridge-shared

pnpm add https://pkg.pr.new/module-federation/core/@module-federation/bridge-shared@ea46ccf

@module-federation/bridge-vue3

pnpm add https://pkg.pr.new/module-federation/core/@module-federation/bridge-vue3@ea46ccf

@module-federation/inject-external-runtime-core-plugin

pnpm add https://pkg.pr.new/module-federation/core/@module-federation/inject-external-runtime-core-plugin@ea46ccf

commit: ea46ccf

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 6, 2026

Bundle Size Report

13 package(s) changed, 27 unchanged.

Package dist + ESM entry

Package Total dist (raw) Delta ESM gzip Delta
@module-federation/bridge-vue3 148.8 kB +2.1 kB (+1.5%) 22.6 kB +140 B (+0.6%)
@module-federation/cli 26.3 kB no change 786 B no change
@module-federation/core 39.1 kB no change 173 B no change
@module-federation/devtools 487.9 kB no change 3.9 kB no change
@module-federation/enhanced 807.3 kB no change 672 B no change
@module-federation/managers 69.8 kB no change 334 B no change
@module-federation/manifest 136.1 kB no change 182 B no change
@module-federation/metro-plugin-rnc-cli 0 B no change 314 B no change
@module-federation/node 193.4 kB no change 217 B no change
@module-federation/runtime 20.1 kB +335 B (+1.7%) 744 B +57 B (+8.3%)
@module-federation/runtime-tools 7.7 kB -65 B (-0.8%) 142 B no change
@module-federation/storybook-addon 77.7 kB no change 100 B no change
@module-federation/utilities 110.6 kB no change 328 B no change

Bundle targets

Package Web bundle (gzip) Delta Node bundle (gzip) Delta
@module-federation/bridge-vue3 17.2 kB no change 16.9 kB no change
@module-federation/cli 2.3 kB -31 B (-1.3%) 2.3 kB -31 B (-1.3%)
@module-federation/core 1.1 kB -32 B (-2.9%) 1.0 kB -31 B (-2.9%)
@module-federation/devtools 21.3 kB -26 B (-0.1%) 21.3 kB -26 B (-0.1%)
@module-federation/enhanced 2.6 kB -43 B (-1.6%) 2.6 kB -43 B (-1.6%)
@module-federation/managers 2.4 kB -27 B (-1.1%) 2.4 kB -27 B (-1.1%)
@module-federation/manifest 6.1 kB -40 B (-0.6%) 6.1 kB -40 B (-0.6%)
@module-federation/metro-plugin-rnc-cli 411 B -26 B (-5.9%) 411 B -26 B (-5.9%)
@module-federation/node 9.2 kB -28 B (-0.3%) 9.2 kB -28 B (-0.3%)
@module-federation/runtime 687 B +13 B (+1.9%) 687 B +13 B (+1.9%)
@module-federation/runtime-tools 89 B no change 89 B no change
@module-federation/storybook-addon 1.9 kB -25 B (-1.3%) 1.7 kB -25 B (-1.4%)
@module-federation/utilities 2.6 kB -31 B (-1.2%) 2.6 kB -31 B (-1.2%)

Tree-shakable entrypoints

Package Export Entry gzip Delta Web bundle (gzip) Delta Node bundle (gzip) Delta Gap (node-web) Delta
@module-federation/runtime ./bundler 177 B no change 687 B +13 B (+1.9%) 687 B +13 B (+1.9%) 0 B 0 B

Consumer scenarios

Scenario Web output (gzip) Delta Node output (gzip) Delta Gap (node-web) Delta
Enhanced remoteEntry 19.8 kB -10 B (-0.0%) 20.8 kB +4 B (+0.0%) +1.0 kB +14 B

Total dist (raw): 6.22 MB (+2.4 kB (+0.0%))
Total ESM gzip: 74.1 kB (+197 B (+0.3%))
Total web bundle (gzip): 178.2 kB (-296 B (-0.2%))
Total node bundle (gzip): 178.6 kB (-295 B (-0.2%))
Tracked ./bundler entry gzip: 556 B (no change)
Tracked ./bundler web bundle (gzip): 4.8 kB (+13 B (+0.3%))
Tracked ./bundler node bundle (gzip): 4.8 kB (+13 B (+0.3%))

Bundle sizes are generated with rslib (Rspack). Package-root metrics preserve the historical report. Tracked subpath exports such as ./bundler are measured separately so ENV_TARGET-driven tree-shaking is visible. Bare imports are externalized to keep package-level sizes consistent, and assets are emitted as resources.

@2heal1 2heal1 merged commit d433ec9 into module-federation:main May 6, 2026
8 of 9 checks passed
@2heal1 2heal1 mentioned this pull request May 21, 2026
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.

2 participants