From 9d7d136b32a8bb0e0d70a502071418c9e4beaa05 Mon Sep 17 00:00:00 2001 From: Charles Lyding <19598772+clydin@users.noreply.github.com> Date: Mon, 18 Dec 2023 19:11:44 -0500 Subject: [PATCH] refactor(@angular-devkit/build-angular): pass full extensions to application builder for dev server Experimental programmatically added build extensions are now passed to the internal application builder when used with the development server. Previously, the plugins were not passed in a manner that would allow them to be used if the `application` builder was selected as the builder for dev server usage. --- .../src/builders/dev-server/vite-server.ts | 27 +++++++++++-------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/packages/angular_devkit/build_angular/src/builders/dev-server/vite-server.ts b/packages/angular_devkit/build_angular/src/builders/dev-server/vite-server.ts index 0362d2f03a36..3c0b04570939 100644 --- a/packages/angular_devkit/build_angular/src/builders/dev-server/vite-server.ts +++ b/packages/angular_devkit/build_angular/src/builders/dev-server/vite-server.ts @@ -28,6 +28,7 @@ import { renderPage } from '../../utils/server-rendering/render-page'; import { getSupportedBrowsers } from '../../utils/supported-browsers'; import { getIndexOutputFile } from '../../utils/webpack-browser-config'; import { buildApplicationInternal } from '../application'; +import { ApplicationBuilderInternalOptions } from '../application/options'; import { buildEsbuildBrowser } from '../browser-esbuild'; import { Schema as BrowserBuilderOptions } from '../browser-esbuild/schema'; import type { NormalizedDevServerOptions } from './options'; @@ -148,19 +149,23 @@ export async function* serveWithVite( const build = builderName === '@angular-devkit/build-angular:browser-esbuild' - ? buildEsbuildBrowser - : buildApplicationInternal; + ? buildEsbuildBrowser.bind( + undefined, + browserOptions, + context, + { write: false }, + extensions?.buildPlugins, + ) + : buildApplicationInternal.bind( + undefined, + browserOptions as ApplicationBuilderInternalOptions, + context, + { write: false }, + { codePlugins: extensions?.buildPlugins }, + ); // TODO: Switch this to an architect schedule call when infrastructure settings are supported - for await (const result of build( - // eslint-disable-next-line @typescript-eslint/no-explicit-any - browserOptions as any, - context, - { - write: false, - }, - extensions?.buildPlugins, - )) { + for await (const result of build()) { assert(result.outputFiles, 'Builder did not provide result files.'); // If build failed, nothing to serve