fix(angular): normalize and handle dev remotes correctly (#26320)
<!-- Please make sure you have read the submission guidelines before posting an PR --> <!-- https://github.com/nrwl/nx/blob/master/CONTRIBUTING.md#-submitting-a-pr --> <!-- Please make sure that your commit message follows our format --> <!-- Example: `fix(nx): must begin with lowercase` --> ## Current Behavior <!-- This is the behavior we have today --> ## Expected Behavior <!-- This is the behavior we should expect with the changes in this PR --> ## Related Issue(s) <!-- Please link the issue being fixed so it gets closed when this is merged. --> Fixes #26169
This commit is contained in:
parent
1ea0589641
commit
ccd16b10dd
@ -54,7 +54,13 @@ export function executeModuleFederationDevSSRBuilder(
|
||||
);
|
||||
}
|
||||
|
||||
validateDevRemotes(options, workspaceProjects);
|
||||
const devServeRemotes = !options.devRemotes
|
||||
? []
|
||||
: Array.isArray(options.devRemotes)
|
||||
? options.devRemotes
|
||||
: [options.devRemotes];
|
||||
|
||||
validateDevRemotes({ devRemotes: devServeRemotes }, workspaceProjects);
|
||||
|
||||
const remotesToSkip = new Set(options.skipRemotes ?? []);
|
||||
const staticRemotes = getStaticRemotes(
|
||||
@ -72,12 +78,6 @@ export function executeModuleFederationDevSSRBuilder(
|
||||
);
|
||||
const remotes = [...staticRemotes, ...dynamicRemotes];
|
||||
|
||||
const devServeRemotes = !options.devRemotes
|
||||
? []
|
||||
: Array.isArray(options.devRemotes)
|
||||
? options.devRemotes
|
||||
: [options.devRemotes];
|
||||
|
||||
const remoteProcessPromises = [];
|
||||
for (const remote of remotes) {
|
||||
const isDev = devServeRemotes.includes(remote);
|
||||
|
||||
@ -3,6 +3,10 @@ import { existsSync, readFileSync } from 'fs';
|
||||
import { logger, ProjectConfiguration } from '@nx/devkit';
|
||||
import { registerTsProject } from '@nx/js/src/internal';
|
||||
|
||||
export type DevRemoteDefinition =
|
||||
| string
|
||||
| { remoteName: string; configuration: string };
|
||||
|
||||
export function getDynamicRemotes(
|
||||
project: ProjectConfiguration,
|
||||
context: import('@angular-devkit/architect').BuilderContext,
|
||||
@ -157,18 +161,12 @@ export function getStaticRemotes(
|
||||
|
||||
export function validateDevRemotes(
|
||||
options: {
|
||||
devRemotes?: (
|
||||
| string
|
||||
| {
|
||||
remoteName: string;
|
||||
configuration: string;
|
||||
}
|
||||
)[];
|
||||
devRemotes: DevRemoteDefinition[];
|
||||
},
|
||||
workspaceProjects: Record<string, ProjectConfiguration>
|
||||
): void {
|
||||
const invalidDevRemotes =
|
||||
options.devRemotes?.filter(
|
||||
options.devRemotes.filter(
|
||||
(remote) =>
|
||||
!(typeof remote === 'string'
|
||||
? workspaceProjects[remote]
|
||||
|
||||
@ -18,6 +18,7 @@ export function normalizeOptions(schema: Schema): NormalizedSchema {
|
||||
return {
|
||||
...schema,
|
||||
buildTarget,
|
||||
devRemotes: schema.devRemotes ?? [],
|
||||
host: schema.host ?? 'localhost',
|
||||
port: schema.port ?? 4200,
|
||||
liveReload: schema.liveReload ?? true,
|
||||
|
||||
@ -107,7 +107,7 @@ export async function* moduleFederationDevServerExecutor(
|
||||
'angular'
|
||||
);
|
||||
|
||||
const remoteNames = options.devRemotes?.map((r) =>
|
||||
const remoteNames = options.devRemotes.map((r) =>
|
||||
typeof r === 'string' ? r : r.remoteName
|
||||
);
|
||||
|
||||
|
||||
@ -1,3 +1,5 @@
|
||||
import type { DevRemoteDefinition } from '../../builders/utilities/module-federation';
|
||||
|
||||
interface BaseSchema {
|
||||
port?: number;
|
||||
host?: string;
|
||||
@ -16,13 +18,7 @@ interface BaseSchema {
|
||||
hmr?: boolean;
|
||||
watch?: boolean;
|
||||
poll?: number;
|
||||
devRemotes?: (
|
||||
| string
|
||||
| {
|
||||
remoteName: string;
|
||||
configuration: string;
|
||||
}
|
||||
)[];
|
||||
devRemotes?: DevRemoteDefinition[];
|
||||
skipRemotes?: string[];
|
||||
pathToManifestFile?: string;
|
||||
static?: boolean;
|
||||
@ -43,6 +39,7 @@ export type SchemaWithBuildTarget = BaseSchema & {
|
||||
export type Schema = SchemaWithBrowserTarget | SchemaWithBuildTarget;
|
||||
|
||||
export type NormalizedSchema = SchemaWithBuildTarget & {
|
||||
devRemotes: DevRemoteDefinition[];
|
||||
liveReload: boolean;
|
||||
open: boolean;
|
||||
ssl: boolean;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user