Skip to content

Commit

Permalink
fix(module-federation): single file server should use project name fo…
Browse files Browse the repository at this point in the history
…r directory (nrwl#20278)
  • Loading branch information
Coly010 authored Nov 20, 2023
1 parent 9b6c642 commit 24b245b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,10 @@ function startStaticRemotesFileServer(

if (!commonOutputDirectory) {
commonOutputDirectory = directoryOfOutputPath;
} else if (commonOutputDirectory !== directoryOfOutputPath) {
} else if (
commonOutputDirectory !== directoryOfOutputPath ||
!outputPath.endsWith(app)
) {
shouldMoveToCommonLocation = true;
}
}
Expand All @@ -119,18 +122,10 @@ function startStaticRemotesFileServer(
for (const app of remotes.staticRemotes) {
const outputPath =
projectGraph.nodes[app].data.targets['build'].options.outputPath;
const outputPathParts = outputPath.split('/');
cpSync(
outputPath,
join(
commonOutputDirectory,
outputPathParts[outputPathParts.length - 1]
),
{
force: true,
recursive: true,
}
);
cpSync(outputPath, join(commonOutputDirectory, app), {
force: true,
recursive: true,
});
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,10 @@ function startStaticRemotesFileServer(

if (!commonOutputDirectory) {
commonOutputDirectory = directoryOfOutputPath;
} else if (commonOutputDirectory !== directoryOfOutputPath) {
} else if (
commonOutputDirectory !== directoryOfOutputPath ||
!outputPath.endsWith(app)
) {
shouldMoveToCommonLocation = true;
}
}
Expand All @@ -70,7 +73,7 @@ function startStaticRemotesFileServer(
const outputPath =
context.projectGraph.nodes[app].data.targets['build'].options
.outputPath;
cpSync(outputPath, commonOutputDirectory, {
cpSync(outputPath, join(commonOutputDirectory, app), {
force: true,
recursive: true,
});
Expand Down

0 comments on commit 24b245b

Please sign in to comment.