From d030a21d37ac6e6a532eddab370dfe36b3c0c638 Mon Sep 17 00:00:00 2001 From: Craigory Coppola Date: Wed, 24 May 2023 16:12:37 -0400 Subject: [PATCH] feat(misc): allow patterns matching for dev remotes and skip remotes (#17185) --- .../module-federation-dev-server.impl.ts | 9 ++++++--- .../module-federation-dev-server.impl.ts | 9 ++++++--- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/packages/angular/src/builders/module-federation-dev-server/module-federation-dev-server.impl.ts b/packages/angular/src/builders/module-federation-dev-server/module-federation-dev-server.impl.ts index 5a6280f97e9bf..9cf8342544535 100644 --- a/packages/angular/src/builders/module-federation-dev-server/module-federation-dev-server.impl.ts +++ b/packages/angular/src/builders/module-federation-dev-server/module-federation-dev-server.impl.ts @@ -10,6 +10,7 @@ import { } from '../utilities/module-federation'; import { existsSync } from 'fs'; import { extname, join } from 'path'; +import { findMatchingProjects } from 'nx/src/utils/find-matching-projects'; export function executeModuleFederationDevServerBuilder( schema: Schema, @@ -47,7 +48,9 @@ export function executeModuleFederationDevServerBuilder( validateDevRemotes(options, workspaceProjects); - const remotesToSkip = new Set(options.skipRemotes ?? []); + const remotesToSkip = new Set( + findMatchingProjects(options.skipRemotes, projectGraph.nodes) ?? [] + ); const staticRemotes = getStaticRemotes( project, context, @@ -66,8 +69,8 @@ export function executeModuleFederationDevServerBuilder( const devServeRemotes = !options.devRemotes ? [] : Array.isArray(options.devRemotes) - ? options.devRemotes - : [options.devRemotes]; + ? findMatchingProjects(options.devRemotes, projectGraph.nodes) + : findMatchingProjects([options.devRemotes], projectGraph.nodes); for (const remote of remotes) { const isDev = devServeRemotes.includes(remote); diff --git a/packages/react/src/executors/module-federation-dev-server/module-federation-dev-server.impl.ts b/packages/react/src/executors/module-federation-dev-server/module-federation-dev-server.impl.ts index 2e52e0e305210..53a00ea29e124 100644 --- a/packages/react/src/executors/module-federation-dev-server/module-federation-dev-server.impl.ts +++ b/packages/react/src/executors/module-federation-dev-server/module-federation-dev-server.impl.ts @@ -9,6 +9,7 @@ import { import * as chalk from 'chalk'; import { waitForPortOpen } from '@nx/web/src/utils/wait-for-port-open'; import { spawn } from 'child_process'; +import { findMatchingProjects } from 'nx/src/utils/find-matching-projects'; type ModuleFederationDevServerOptions = WebDevServerOptions & { devRemotes?: string | string[]; @@ -37,7 +38,9 @@ export default async function* moduleFederationDevServer( ); } - const remotesToSkip = new Set(options.skipRemotes ?? []); + const remotesToSkip = new Set( + findMatchingProjects(options.skipRemotes ?? [], context.projectGraph.nodes) + ); const knownRemotes = (moduleFederationConfig.remotes ?? []).filter((r) => { const validRemote = Array.isArray(r) ? r[0] : r; return !remotesToSkip.has(validRemote); @@ -49,8 +52,8 @@ export default async function* moduleFederationDevServer( const devServeApps = !options.devRemotes ? [] : Array.isArray(options.devRemotes) - ? options.devRemotes - : [options.devRemotes]; + ? findMatchingProjects(options.devRemotes, context.projectGraph.nodes) + : findMatchingProjects([options.devRemotes], context.projectGraph.nodes); logger.info( `NX Starting module federation dev-server for ${chalk.bold(