Skip to content

Commit

Permalink
feat(misc): allow patterns matching for dev remotes and skip remotes (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
AgentEnder committed May 24, 2023
1 parent 6d586dd commit d030a21
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand All @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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[];
Expand Down Expand Up @@ -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);
Expand All @@ -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(
Expand Down

1 comment on commit d030a21

@vercel
Copy link

@vercel vercel bot commented on d030a21 May 24, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

nx-dev – ./

nx-dev-nrwl.vercel.app
nx.dev
nx-five.vercel.app
nx-dev-git-master-nrwl.vercel.app

Please sign in to comment.