Skip to content

Commit

Permalink
fix(module-federation): ensure shared packages can be shared from host
Browse files Browse the repository at this point in the history
  • Loading branch information
Coly010 committed Aug 19, 2024
1 parent b91d788 commit f20624b
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,12 @@ export async function* moduleFederationDevServerExecutor(
options.staticRemotesPort ??= remotes.staticRemotePort;

// Set NX_MF_DEV_REMOTES for the Nx Runtime Library Control Plugin
process.env.NX_MF_DEV_REMOTES = JSON.stringify(
remotes.devRemotes.map((r) => (typeof r === 'string' ? r : r.remoteName))
);
process.env.NX_MF_DEV_REMOTES = JSON.stringify([
...(remotes.devRemotes.map((r) =>
typeof r === 'string' ? r : r.remoteName
) ?? []),
project.name,
]);

const staticRemotesConfig = parseStaticRemotesConfig(
[...remotes.staticRemotes, ...remotes.dynamicRemotes],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,10 @@ export async function* moduleFederationSsrDevServerExecutor(
);

// Set NX_MF_DEV_REMOTES for the Nx Runtime Library Control Plugin
process.env.NX_MF_DEV_REMOTES = JSON.stringify(options.devRemotes);
process.env.NX_MF_DEV_REMOTES = JSON.stringify([
...(options.devRemotes ?? []),
project.name,
]);

const devRemotes = await startRemotes(
remotes.devRemotes,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -332,9 +332,12 @@ export default async function* moduleFederationDevServer(
options.staticRemotesPort ??= remotes.staticRemotePort;

// Set NX_MF_DEV_REMOTES for the Nx Runtime Library Control Plugin
process.env.NX_MF_DEV_REMOTES = JSON.stringify(
remotes.devRemotes.map((r) => (typeof r === 'string' ? r : r.remoteName))
);
process.env.NX_MF_DEV_REMOTES = JSON.stringify([
...(remotes.devRemotes.map((r) =>
typeof r === 'string' ? r : r.remoteName
) ?? []),
p.name,
]);

const staticRemotesConfig = parseStaticRemotesConfig(
[...remotes.staticRemotes, ...remotes.dynamicRemotes],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -310,9 +310,12 @@ export default async function* moduleFederationSsrDevServer(

options.staticRemotesPort ??= remotes.staticRemotePort;

process.env.NX_MF_DEV_REMOTES = JSON.stringify(
remotes.devRemotes.map((r) => (typeof r === 'string' ? r : r.remoteName))
);
process.env.NX_MF_DEV_REMOTES = JSON.stringify([
...(remotes.devRemotes.map((r) =>
typeof r === 'string' ? r : r.remoteName
) ?? []),
projectConfig.name,
]);

const staticRemotesConfig = parseStaticSsrRemotesConfig(
[...remotes.staticRemotes, ...remotes.dynamicRemotes],
Expand Down

0 comments on commit f20624b

Please sign in to comment.