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 remotesToSkip = new Set(options.skipRemotes ?? []);
|
||||||
const staticRemotes = getStaticRemotes(
|
const staticRemotes = getStaticRemotes(
|
||||||
@ -72,12 +78,6 @@ export function executeModuleFederationDevSSRBuilder(
|
|||||||
);
|
);
|
||||||
const remotes = [...staticRemotes, ...dynamicRemotes];
|
const remotes = [...staticRemotes, ...dynamicRemotes];
|
||||||
|
|
||||||
const devServeRemotes = !options.devRemotes
|
|
||||||
? []
|
|
||||||
: Array.isArray(options.devRemotes)
|
|
||||||
? options.devRemotes
|
|
||||||
: [options.devRemotes];
|
|
||||||
|
|
||||||
const remoteProcessPromises = [];
|
const remoteProcessPromises = [];
|
||||||
for (const remote of remotes) {
|
for (const remote of remotes) {
|
||||||
const isDev = devServeRemotes.includes(remote);
|
const isDev = devServeRemotes.includes(remote);
|
||||||
|
|||||||
@ -3,6 +3,10 @@ import { existsSync, readFileSync } from 'fs';
|
|||||||
import { logger, ProjectConfiguration } from '@nx/devkit';
|
import { logger, ProjectConfiguration } from '@nx/devkit';
|
||||||
import { registerTsProject } from '@nx/js/src/internal';
|
import { registerTsProject } from '@nx/js/src/internal';
|
||||||
|
|
||||||
|
export type DevRemoteDefinition =
|
||||||
|
| string
|
||||||
|
| { remoteName: string; configuration: string };
|
||||||
|
|
||||||
export function getDynamicRemotes(
|
export function getDynamicRemotes(
|
||||||
project: ProjectConfiguration,
|
project: ProjectConfiguration,
|
||||||
context: import('@angular-devkit/architect').BuilderContext,
|
context: import('@angular-devkit/architect').BuilderContext,
|
||||||
@ -157,18 +161,12 @@ export function getStaticRemotes(
|
|||||||
|
|
||||||
export function validateDevRemotes(
|
export function validateDevRemotes(
|
||||||
options: {
|
options: {
|
||||||
devRemotes?: (
|
devRemotes: DevRemoteDefinition[];
|
||||||
| string
|
|
||||||
| {
|
|
||||||
remoteName: string;
|
|
||||||
configuration: string;
|
|
||||||
}
|
|
||||||
)[];
|
|
||||||
},
|
},
|
||||||
workspaceProjects: Record<string, ProjectConfiguration>
|
workspaceProjects: Record<string, ProjectConfiguration>
|
||||||
): void {
|
): void {
|
||||||
const invalidDevRemotes =
|
const invalidDevRemotes =
|
||||||
options.devRemotes?.filter(
|
options.devRemotes.filter(
|
||||||
(remote) =>
|
(remote) =>
|
||||||
!(typeof remote === 'string'
|
!(typeof remote === 'string'
|
||||||
? workspaceProjects[remote]
|
? workspaceProjects[remote]
|
||||||
|
|||||||
@ -18,6 +18,7 @@ export function normalizeOptions(schema: Schema): NormalizedSchema {
|
|||||||
return {
|
return {
|
||||||
...schema,
|
...schema,
|
||||||
buildTarget,
|
buildTarget,
|
||||||
|
devRemotes: schema.devRemotes ?? [],
|
||||||
host: schema.host ?? 'localhost',
|
host: schema.host ?? 'localhost',
|
||||||
port: schema.port ?? 4200,
|
port: schema.port ?? 4200,
|
||||||
liveReload: schema.liveReload ?? true,
|
liveReload: schema.liveReload ?? true,
|
||||||
|
|||||||
@ -107,7 +107,7 @@ export async function* moduleFederationDevServerExecutor(
|
|||||||
'angular'
|
'angular'
|
||||||
);
|
);
|
||||||
|
|
||||||
const remoteNames = options.devRemotes?.map((r) =>
|
const remoteNames = options.devRemotes.map((r) =>
|
||||||
typeof r === 'string' ? r : r.remoteName
|
typeof r === 'string' ? r : r.remoteName
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@ -1,3 +1,5 @@
|
|||||||
|
import type { DevRemoteDefinition } from '../../builders/utilities/module-federation';
|
||||||
|
|
||||||
interface BaseSchema {
|
interface BaseSchema {
|
||||||
port?: number;
|
port?: number;
|
||||||
host?: string;
|
host?: string;
|
||||||
@ -16,13 +18,7 @@ interface BaseSchema {
|
|||||||
hmr?: boolean;
|
hmr?: boolean;
|
||||||
watch?: boolean;
|
watch?: boolean;
|
||||||
poll?: number;
|
poll?: number;
|
||||||
devRemotes?: (
|
devRemotes?: DevRemoteDefinition[];
|
||||||
| string
|
|
||||||
| {
|
|
||||||
remoteName: string;
|
|
||||||
configuration: string;
|
|
||||||
}
|
|
||||||
)[];
|
|
||||||
skipRemotes?: string[];
|
skipRemotes?: string[];
|
||||||
pathToManifestFile?: string;
|
pathToManifestFile?: string;
|
||||||
static?: boolean;
|
static?: boolean;
|
||||||
@ -43,6 +39,7 @@ export type SchemaWithBuildTarget = BaseSchema & {
|
|||||||
export type Schema = SchemaWithBrowserTarget | SchemaWithBuildTarget;
|
export type Schema = SchemaWithBrowserTarget | SchemaWithBuildTarget;
|
||||||
|
|
||||||
export type NormalizedSchema = SchemaWithBuildTarget & {
|
export type NormalizedSchema = SchemaWithBuildTarget & {
|
||||||
|
devRemotes: DevRemoteDefinition[];
|
||||||
liveReload: boolean;
|
liveReload: boolean;
|
||||||
open: boolean;
|
open: boolean;
|
||||||
ssl: boolean;
|
ssl: boolean;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user