Skip to content

Commit 8b462c4

Browse files
committed
fix(module-federation): dynamic federation helpers should normalize remote names
1 parent ba1641d commit 8b462c4

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

packages/module-federation/src/utils/get-remotes-for-host.ts

+10-1
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,16 @@ export function getRemotes(
102102
(r) => !remotesToSkip.has(r)
103103
);
104104

105-
const knownDynamicRemotes = dynamicRemotes.filter(
105+
// With dynamic remotes, the manifest file may contain the names with `_` due to MF limitations on naming
106+
// The project graph might contain these names with `-` rather than `_`. Check for both.
107+
// This can occur after migration of existing remotes past Nx 19.8
108+
let normalizedDynamicRemotes = dynamicRemotes.map((r) => {
109+
if (context.projectGraph.nodes[r.replace(/_/g, '-')]) {
110+
return r.replace(/_/g, '-');
111+
}
112+
return r;
113+
});
114+
const knownDynamicRemotes = normalizedDynamicRemotes.filter(
106115
(r) => !remotesToSkip.has(r) && context.projectGraph.nodes[r]
107116
);
108117

0 commit comments

Comments
 (0)