Skip to content

Conversation

ScriptedAlchemy
Copy link
Member

Summary

  • Move alias-aware path equality to NMF afterResolve for determinism.
  • Cache target resolutions; track file/context deps to improve watch fidelity and reduce resolver churn.

Tests

  • Updated NMF-related tests to mock afterResolve where needed.

Notes

  • No API changes. Behavior preserved; improves stability with aliases and watch mode.

… caching

Move path equality checks to afterResolve for determinism.

Cache target resolutions and track deps to reduce resolver churn.
Align tests with plugin tapping afterResolve to prevent undefined hook errors.
Copy link

changeset-bot bot commented Sep 12, 2025

🦋 Changeset detected

Latest commit: 095f6aa

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

This PR includes changesets to release 36 packages
Name Type
@module-federation/enhanced Patch
@module-federation/modern-js Patch
@module-federation/nextjs-mf Patch
@module-federation/node Patch
@module-federation/rsbuild-plugin Patch
@module-federation/rspress-plugin Patch
@module-federation/storybook-addon Patch
@module-federation/modernjsapp Patch
remote5 Patch
website-new Patch
@module-federation/runtime Patch
@module-federation/rspack Patch
@module-federation/webpack-bundler-runtime Patch
@module-federation/sdk Patch
@module-federation/runtime-tools Patch
@module-federation/managers Patch
@module-federation/manifest Patch
@module-federation/dts-plugin Patch
@module-federation/third-party-dts-extractor Patch
@module-federation/devtools Patch
@module-federation/bridge-react Patch
@module-federation/bridge-vue3 Patch
@module-federation/bridge-shared Patch
@module-federation/bridge-react-webpack-plugin Patch
@module-federation/retry-plugin Patch
@module-federation/data-prefetch Patch
@module-federation/error-codes Patch
@module-federation/inject-external-runtime-core-plugin Patch
@module-federation/runtime-core Patch
create-module-federation Patch
@module-federation/cli Patch
@module-federation/metro Patch
@module-federation/metro-plugin-rnef Patch
@module-federation/metro-plugin-rnc-cli Patch
@module-federation/esbuild 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

@ScriptedAlchemy ScriptedAlchemy changed the base branch from main to feat/share-resolver September 12, 2025 06:02
Copy link

netlify bot commented Sep 12, 2025

Deploy Preview for module-federation-docs ready!

Name Link
🔨 Latest commit c701d85
🔍 Latest deploy log https://app.netlify.com/projects/module-federation-docs/deploys/68c3b75e47fcdb0008df3a04
😎 Deploy Preview https://deploy-preview-4061--module-federation-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

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

Copy link

Codex Review: Here are some suggestions.

// 3b. Prefix provided requests (configured as "foo/")
if (!resolvedProvideMap.has(lookupKeyForResource)) {
for (const [
prefixLookupKey,
originalPrefixConfig,
] of prefixMatchProvides) {
if (!layerMatches(originalPrefixConfig.layer, moduleLayer))
continue;
const configuredPrefix =
originalPrefixConfig.request ||
prefixLookupKey.split('?')[0];
const matched = handlePrefixMatch(
originalPrefixConfig,
configuredPrefix,
normalizedAfterNM,
normalizedAfterNM,
moduleLayer,
resource,
resourceResolveData,
lookupKeyForResource,
resolveData,
);
if (matched) break;

[P1] Respect allowNodeModulesSuffixMatch when inferring prefix aliases

The new Stage 3 alias logic always calls handlePrefixMatch for every prefixed provide entry when a bare request resolves into node_modules. Unlike the previous implementation, this block no longer checks allowNodeModulesSuffixMatch (formerly nodeModulesReconstructedLookup) before matching by path suffix. As a result, configurations such as shared: { 'lodash/': { …, allowNodeModulesSuffixMatch: false } } will now be treated as alias-compatible and the provider will register the module even when the user did not opt in, potentially sharing unintended modules or colliding with distinct packages. Stage 2 still guards on the flag, so the omission here looks accidental; the flag should be honored before calling handlePrefixMatch in Stage 3.


Reply with @codex fix comments to fix any unresolved comments.

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, or 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 fix this CI failure" or "@codex address that feedback".

Skip data: resources in afterResolve and createModule.

Preserve virtual module handling by webpack.

Broaden afterResolve candidates for deep-path shares.

Example: next/dist/compiled/react alias.

Avoid converting explicit relative or absolute requests into consumes.

Preserves local nested resolution for deep sharing.

Keep prefix and node_modules suffix matching as before.

Add a changeset for @module-federation/enhanced.
@ScriptedAlchemy
Copy link
Member Author

Summary of fixes added in 095f6aa:

  • Add data: URI guards in afterResolve and createModule so webpack handles virtual modules; fixes container virtual-entry regression.
  • Expand alias-aware consume matching in afterResolve to include deep-path shares starting with the resolved package name (e.g. next/dist/compiled/react), ensuring aliased modules are consumed via federation when configured.
  • Avoid converting explicit relative/absolute requests into consumes to preserve local nested resolution for deep module sharing.
  • Preserve existing prefix and node_modules suffix matching behavior.

Validation:

  • Ran 'pnpm enhanced:jest' locally; all suites now pass (31/31, 614 tests). Previously failing cases fixed:
    • sharing/share-deep-module (deep-path version resolves to 2.0.0)
    • sharing/share-with-aliases and share-with-aliases-provide-only (react alias consumed via webpack/sharing/*)
    • container/virtual-entry compiles without error.

Added a changeset for @module-federation/enhanced (patch).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant