Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
1c7ead0
refactor(enhanced): resolve alias-aware consumes in afterResolve with…
ScriptedAlchemy Sep 12, 2025
c701d85
test(enhanced): mock afterResolve hook in NMF tests
ScriptedAlchemy Sep 12, 2025
116e775
Merge branch 'feat/share-resolver' into gpt-alias-resolver-refactor
ScriptedAlchemy Sep 12, 2025
095f6aa
fix(enhanced): alias-aware ConsumeSharedPlugin + data URI guard
ScriptedAlchemy Sep 12, 2025
953b8ab
chore: patch
ScriptedAlchemy Sep 19, 2025
341e045
ci(core): enable tag push and npm publish in release workflow
ScriptedAlchemy Sep 19, 2025
5f44b8a
chore: x
ScriptedAlchemy Sep 19, 2025
038ebe8
ci(core): refine release workflow (npm auth, registry, branch fetch)
ScriptedAlchemy Sep 19, 2025
5e0d7e6
chore(core): merge origin/main into gpt-alias-resolver-refactor (theirs)
ScriptedAlchemy Sep 20, 2025
83993f8
fix(enhanced): guard missing hooks in tests (afterResolve, finishModu…
ScriptedAlchemy Sep 20, 2025
78f91a0
Merge branch 'feat/share-resolver' into gpt-alias-resolver-refactor
ScriptedAlchemy Sep 22, 2025
72211ab
refactor: always register finishModules hook
ScriptedAlchemy Sep 22, 2025
d4be790
chore(module-federation): restore release workflow from main
ScriptedAlchemy Sep 22, 2025
b5ccfd0
Merge branch 'feat/share-resolver' into gpt-alias-resolver-refactor
ScriptedAlchemy Sep 22, 2025
8c4a777
Merge branch 'feat/share-resolver' into gpt-alias-resolver-refactor
ScriptedAlchemy Sep 27, 2025
47fd166
feat(enhanced): gate alias-aware consumption behind experiments.alias…
ScriptedAlchemy Sep 29, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions .changeset/fix-alias-aware-consume-plugin.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
'@module-federation/enhanced': patch
---

fix(enhanced): ConsumeSharedPlugin alias-aware and virtual resource handling

- Skip `data:` (virtual) resources in `afterResolve` and `createModule` so webpack's scheme resolver handles them (fixes container virtual-entry compile failure)
- Broaden alias-aware matching in `afterResolve` to include deep-path shares that start with the resolved package name (e.g. `next/dist/compiled/react`), ensuring aliased modules are consumed from federation when configured
- Avoid converting explicit relative/absolute requests into consumes to preserve local nested resolution (fixes deep module sharing version selection)
- Keep prefix and node_modules suffix matching intact; no behavior change there

These changes restore expected behavior for:
- Virtual entry compilation
- Deep module sharing (distinct versions for nested paths)
- Alias-based sharing (Next.js compiled React)

4 changes: 2 additions & 2 deletions .github/workflows/e2e-manifest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ jobs:

- name: E2E Test for Manifest Demo Development
if: steps.check-ci.outcome == 'success'
run: pnpm run app:manifest:dev & echo "done" && npx wait-on tcp:3009 && npx wait-on tcp:3012 && npx wait-on http://127.0.0.1:4001/ && npx nx run-many --target=e2e --projects=manifest-webpack-host --parallel=2 && npx kill-port 3013 3009 3010 3011 3012 4001
run: node tools/scripts/run-manifest-e2e.mjs --mode=dev

- name: E2E Test for Manifest Demo Production
if: steps.check-ci.outcome == 'success'
run: pnpm run app:manifest:prod & echo "done" && npx wait-on tcp:3009 && npx wait-on tcp:3012 && npx wait-on http://127.0.0.1:4001/ && npx nx run-many --target=e2e --projects=manifest-webpack-host --parallel=1 && npx kill-port 3013 3009 3010 3011 3012 4001
run: node tools/scripts/run-manifest-e2e.mjs --mode=prod
7 changes: 4 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ ssg
__mocks__/

# test mock modules
!packages/enhanced/test/configCases/**/**/node_modules
!packages/enhanced/test/configCases/sharing/share-with-aliases/node_modules/next/dist
!packages/enhanced/test/configCases/sharing/share-with-aliases-provide-only/node_modules/next/dist
# Keep ALL test configCases node_modules (and all nested files) tracked,
# so we don't need per-path exceptions like next/dist.
!packages/enhanced/test/configCases/**/node_modules/
!packages/enhanced/test/configCases/**/node_modules/**
1 change: 1 addition & 0 deletions nx.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"$schema": "./node_modules/nx/schemas/nx-schema.json",
"useDaemonProcess": false,
"targetDefaults": {
"build": {
"inputs": ["production", "^production"],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,13 @@ export interface ConsumeSharedPluginOptions {
* Share scope name used for all consumed modules (defaults to 'default').
*/
shareScope?: string | string[];
/**
* Experimental features configuration.
*/
experiments?: {
/** Enable alias-aware consuming via NormalModuleFactory.afterResolve (experimental). */
aliasConsumption?: boolean;
};
}
/**
* Modules that should be consumed from share scope. Property names are used to match requested modules in this compilation. Relative requests are resolved, module requests are matched unresolved, absolute paths will match resolved requests. A trailing slash will match all requests with this prefix. In this case shareKey must also have a trailing slash.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,13 @@ export interface SharePluginOptions {
* Modules that should be shared in the share scope. When provided, property names are used to match requested modules in this compilation.
*/
shared: Shared;
/**
* Experimental features configuration.
*/
experiments?: {
/** Enable alias-aware consuming via NormalModuleFactory.afterResolve (experimental). */
aliasConsumption?: boolean;
};
}
/**
* Modules that should be shared in the share scope. Property names are used to match requested modules in this compilation. Relative requests are resolved, module requests are matched unresolved, absolute paths will match resolved requests. A trailing slash will match all requests with this prefix. In this case shareKey must also have a trailing slash.
Expand Down
11 changes: 9 additions & 2 deletions packages/enhanced/src/lib/container/ModuleFederationPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,8 @@ class ModuleFederationPlugin implements WebpackPluginInstance {
(new RemoteEntryPlugin(options) as unknown as WebpackPluginInstance).apply(
compiler,
);

// Do not use process.env for alias consumption; flag is forwarded via options
if (options.experiments?.provideExternalRuntime) {
if (options.exposes) {
throw new Error(
Expand Down Expand Up @@ -212,10 +214,15 @@ class ModuleFederationPlugin implements WebpackPluginInstance {
}).apply(compiler);
}
if (options.shared) {
new SharePlugin({
// Build SharePlugin options and pass through aliasConsumption directly
const shareOpts = {
shared: options.shared,
shareScope: options.shareScope,
}).apply(compiler);
experiments: {
aliasConsumption: options.experiments?.aliasConsumption,
},
};
new SharePlugin(shareOpts).apply(compiler);
}
});

Expand Down
Loading