Skip to content

Conversation

ScriptedAlchemy
Copy link
Member

Summary

  • Add alias-aware matching to ProvideSharedPlugin and ConsumeSharedPlugin so aliased imports (e.g., reactnext/dist/compiled/react) are recognized as shared when only the target is in shared config
  • Add comprehensive test coverage including new config test case and unit tests for alias-aware behavior

Changes

  • ProvideSharedPlugin: Add Stage 3 to compare resolved module's node_modules suffix against provided requests, respecting layer and filter rules
  • ConsumeSharedPlugin: Add Stage 6 to resolve aliased requests against shared config using webpack's resolver
  • Tests: New share-with-aliases-provide-only config test case and focused unit test for provide-only alias-aware behavior
  • Utilities: Add aliasResolver.ts for extracting node_modules paths and path normalization

This enhancement enables Module Federation to work seamlessly with bundler alias configurations (Next.js, Webpack aliases, etc.) without requiring manual workarounds.

…shared modules

- Add opencode.json with alias-resolver agent for fixing webpack alias issues
- Add comprehensive prompt documentation for Module Federation alias resolution
- Add failing test case demonstrating shared module alias bug
- Add AGENTS.md with repository guidelines and commands
- Add alias resolution support for shared modules
- Relax strict instance matching to package identity checks
- Implement version inference from module source
- Add caching for consume shared modules
- Update test expectations for alias sharing
… provide hook

- ConsumeSharedPlugin: simplify factorize flow (no behavior change)

- Rename nodeModulesReconstructedLookup to allowNodeModulesSuffixMatch

- ProvideSharedPlugin: add helpers for layer checks and prefix matches

- Mark alias resolver docs out of scope

BREAKING CHANGE: option renamed to allowNodeModulesSuffixMatch
- Use descriptionFileData to build candidates (pkgName/relative path)

- Match candidates in consume and provide hooks

- Keep behavior/gating for suffix/prefix matching
This reverts commit 667a941.
…dules

- Add Stage 3 in ProvideSharedPlugin to recognize aliased imports when only target is shared
- Add Stage 6 in ConsumeSharedPlugin to resolve aliased requests against shared config
- Add aliasResolver utility for extracting node_modules paths
- Add provide-only config test case and unit test for alias-aware behavior
- Clean up existing alias test assertions
- Update .gitignore to include test mock node_modules
Copy link

changeset-bot bot commented Sep 8, 2025

🦋 Changeset detected

Latest commit: 978dc15

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

Copy link

netlify bot commented Sep 8, 2025

Deploy Preview for module-federation-docs ready!

Name Link
🔨 Latest commit 978dc15
🔍 Latest deploy log https://app.netlify.com/projects/module-federation-docs/deploys/68e6f8b870c687000819a0d6
😎 Deploy Preview https://deploy-preview-4049--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.

@ScriptedAlchemy
Copy link
Member Author

@codex review pr

Copy link

@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.

ℹ️ 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

Comment on lines 94 to 98
request: options.request || options.import || key,
exclude: options.exclude,
include: options.include,
nodeModulesReconstructedLookup:
options.nodeModulesReconstructedLookup,
allowNodeModulesSuffixMatch: options.allowNodeModulesSuffixMatch,
},

Choose a reason for hiding this comment

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

P1 Badge Preserve legacy nodeModulesReconstructedLookup option

The constructors for SharePlugin and ConsumeSharedPlugin now only read allowNodeModulesSuffixMatch and the schema removed nodeModulesReconstructedLookup. Existing configurations that still use the prior key (including experiments.nodeModulesReconstructedLookup) will silently lose the suffix‑matching behaviour after upgrading, even though nothing in the release notes indicates a breaking change. Consider accepting both property names or providing a migration path so current users don’t regress when they upgrade.

Useful? React with 👍 / 👎.

Copy link
Member Author

Choose a reason for hiding this comment

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

we dont want to preserve legacy

# Conflicts:
#	.gitignore
#	packages/enhanced/test/unit/sharing/ConsumeSharedPlugin/ConsumeSharedPlugin.createConsumeSharedModule.test.ts
#	packages/enhanced/test/unit/sharing/ConsumeSharedPlugin/ConsumeSharedPlugin.exclude-filtering.test.ts
#	packages/enhanced/test/unit/sharing/SharePlugin.improved.test.ts
#	packages/enhanced/test/unit/sharing/resolveMatchedConfigs.test.ts
…solver"

This reverts commit 5270815, reversing
changes made to d7c4772.
# Conflicts:
#	tools/scripts/run-manifest-e2e.mjs
# Conflicts:
#	packages/enhanced/test/unit/sharing/ConsumeSharedPlugin/ConsumeSharedPlugin.integration.test.ts
#	packages/enhanced/test/unit/sharing/ConsumeSharedPlugin/helpers.ts
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