From 289c1cb470bea909ec9e974776ffe8c71169a9d7 Mon Sep 17 00:00:00 2001 From: Colum Ferry Date: Fri, 16 Aug 2024 14:33:58 +0100 Subject: [PATCH] fix(angular): module-federation-ssr-dev-server should call correct builder (#27477) ## Current Behavior `module-federation-ssr-dev-server` is calling `dev-server` builder instead of `ssr-dev-server` builder ## Expected Behavior `module-federation-ssr-dev-server` calls the correct builder ## Related Issue(s) Fixes # (cherry picked from commit 829f5fa7583e5e8b477757a09d05ac9fac9a32ef) --- .../module-federation-ssr-dev-server.impl.ts | 10 ++++++++-- packages/nx/src/adapter/ngcli-adapter.ts | 4 ++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/packages/angular/src/executors/module-federation-ssr-dev-server/module-federation-ssr-dev-server.impl.ts b/packages/angular/src/executors/module-federation-ssr-dev-server/module-federation-ssr-dev-server.impl.ts index 87172201cb2a9..016b1f002b086 100644 --- a/packages/angular/src/executors/module-federation-ssr-dev-server/module-federation-ssr-dev-server.impl.ts +++ b/packages/angular/src/executors/module-federation-ssr-dev-server/module-federation-ssr-dev-server.impl.ts @@ -25,7 +25,7 @@ import { createBuilderContext } from 'nx/src/adapter/ngcli-adapter'; import { normalizeOptions } from './lib/normalize-options'; import { waitForPortOpen } from '@nx/web/src/utils/wait-for-port-open'; import { startSsrRemoteProxies } from '@nx/webpack/src/utils/module-federation/start-ssr-remote-proxies'; -import { executeDevServerBuilder } from '../../builders/dev-server/dev-server.impl'; +import { getInstalledAngularVersionInfo } from '../utilities/angular-version-utils'; export async function* moduleFederationSsrDevServerExecutor( schema: Schema, @@ -34,8 +34,14 @@ export async function* moduleFederationSsrDevServerExecutor( const nxBin = require.resolve('nx/bin/nx'); const options = normalizeOptions(schema); + const { major: angularMajorVersion } = getInstalledAngularVersionInfo(); + const { executeSSRDevServerBuilder } = + angularMajorVersion >= 17 + ? require('@angular-devkit/build-angular') + : require('@nguniversal/builders'); + const currIter = eachValueFrom( - executeDevServerBuilder( + executeSSRDevServerBuilder( options, await createBuilderContext( { diff --git a/packages/nx/src/adapter/ngcli-adapter.ts b/packages/nx/src/adapter/ngcli-adapter.ts index ea461cec888f4..3ceaf2e0f3ba3 100644 --- a/packages/nx/src/adapter/ngcli-adapter.ts +++ b/packages/nx/src/adapter/ngcli-adapter.ts @@ -167,8 +167,8 @@ export async function createBuilderContext( logger: getLogger(), id: 1, currentDirectory: process.cwd(), - scheduleTarget: architect.scheduleTarget, - scheduleBuilder: architect.scheduleBuilder, + scheduleTarget: (...args) => architect.scheduleTarget(...args), + scheduleBuilder: (...args) => architect.scheduleBuilder(...args), addTeardown(teardown: () => Promise | void) { // No-op as Nx doesn't require an implementation of this function return;