fix: select import:false shared providers by strategy#841
Merged
gioboa merged 2 commits intoJun 22, 2026
Merged
Conversation
commit: |
Contributor
Author
|
@gioboa CI was failing because an integration test still asserted the old first-key provider selection logic. |
gioboa
reviewed
Jun 21, 2026
gioboa
left a comment
Collaborator
There was a problem hiding this comment.
Thanks for this PR, I'll check this out in few hours π
This was referenced Jun 26, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Summary
This fixes provider selection for
import: falseshared modules when the shared scope contains multiple providers for the same package.Previously, the remote entry bridge picked the first provider from the shared scope object. That made the selected shared module depend on object key order rather than the configured share strategy, provider load state, version ordering, and strict version behavior.
When
import: falseshared modules are configured, the generated remote entry imports the public runtime share helper and emits a small bridge for selecting providers before seeding the__mf_module_cache__entry.This aligns the
import: falsebridge with the documentedshareStrategybehavior forversion-firstandloaded-first.Problem
The
import: falsebridge selected a provider like this:When multiple providers existed for the same shared package, this could select whichever version appeared first in the object.
Example failure before this change:
If
18.3.1was inserted first,Object.keys(versions)[0]selected the React 18 provider. A remote configured withreactassingleton,import: false, andrequiredVersion: '^19.0.0'could then seed__mf_module_cache__.share['default:react']with React 18 before the exposed module imported React. Since singleton cache entries are reused, later shared imports could keep reading the wrong provider instead of the React 19 provider expected byversion-first.The generated share config also did not include
strictVersion, so strict version mismatch handling was not preserved when the bridge delegated selection to the runtime helper.Changes
strictVersionto generated local and used shared configs invirtualRemoteEntry.tsandgenerateUsedSharedPreloadConfig.remoteEntryonly whenimport: falseshared modules are configured:sharedProviderSelectionHelperCodeandneedsSharedProviderSelectionHelper.sharefrom@module-federation/runtime/helpersfor that bridge so strategy, range, singleton, and strict-version decisions are delegated to the runtimegetRegisteredSharepath:runtimeShareimport.@module-federation/runtimealias to an exact match and added animport: false-only exact alias for@module-federation/runtime/helpersderived from the same runtime implementation:getRuntimeHelpersImplementationandconfigalias setup. This keeps customimplementationconsumers and strict pnpm installs on one runtime package.version-first, the bridge uses a selection-only provider map withloaded,loading, andlibneutralized before delegating to the runtime helper:__mfCreateProviderSelectionVersions. This prevents an already materialized lower version from winning over a higher compatible provider duringimport: falsecache seeding.import: falsebridge to use the helper instead of the first object key for bothglobal share pre-seedingandshared init argument bridging.virtualRemoteEntry.test.tsandindex.test.ts.