-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(module-federation): map static remote locations correctly (#21709)
(cherry picked from commit 7f4c97e)
- Loading branch information
1 parent
db78715
commit dc48960
Showing
7 changed files
with
140 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
packages/angular/src/executors/module-federation-dev-server/lib/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
export * from './build-static-remotes'; | ||
export * from './normalize-options'; | ||
export * from './parse-static-remotes-config'; | ||
export * from './start-dev-remotes'; | ||
export * from './start-static-remotes-file-server'; |
33 changes: 33 additions & 0 deletions
33
...ges/angular/src/executors/module-federation-dev-server/lib/parse-static-remotes-config.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import type { ExecutorContext } from '@nx/devkit'; | ||
import { basename, dirname } from 'path'; | ||
|
||
export type StaticRemoteConfig = { | ||
basePath: string; | ||
outputPath: string; | ||
urlSegment: string; | ||
}; | ||
|
||
export type StaticRemotesConfig = { | ||
remotes: string[]; | ||
config: Record<string, StaticRemoteConfig> | undefined; | ||
}; | ||
|
||
export function parseStaticRemotesConfig( | ||
staticRemotes: string[] | undefined, | ||
context: ExecutorContext | ||
): StaticRemotesConfig { | ||
if (!staticRemotes?.length) { | ||
return { remotes: [], config: undefined }; | ||
} | ||
|
||
const config: Record<string, StaticRemoteConfig> = {}; | ||
for (const app of staticRemotes) { | ||
const outputPath = | ||
context.projectGraph.nodes[app].data.targets['build'].options.outputPath; | ||
const basePath = dirname(outputPath); | ||
const urlSegment = basename(outputPath); | ||
config[app] = { basePath, outputPath, urlSegment }; | ||
} | ||
|
||
return { remotes: staticRemotes, config }; | ||
} |
42 changes: 18 additions & 24 deletions
42
...ngular/src/executors/module-federation-dev-server/lib/start-static-remotes-file-server.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters