From ddeb2b2b93eaa9d8b659d17357aa2b7a9dc509ce Mon Sep 17 00:00:00 2001 From: Charles Lyding <19598772+clydin@users.noreply.github.com> Date: Tue, 20 Aug 2024 10:21:23 -0400 Subject: [PATCH] fix(@angular-devkit/build-angular): remove outdated browser-esbuild option warning The `resourcesOutputPath` option from the browser builder is supported as of 18.2. The unsupported warning is now removed. The warning logic has also been consolidated now that there are only several warnings left. (cherry picked from commit 0b161bc7616bef9a8f1f9113a50b07291635159d) --- .../builder-status-warnings.ts | 51 ------------------- .../src/builders/browser-esbuild/index.ts | 20 ++++++-- 2 files changed, 17 insertions(+), 54 deletions(-) delete mode 100644 packages/angular_devkit/build_angular/src/builders/browser-esbuild/builder-status-warnings.ts diff --git a/packages/angular_devkit/build_angular/src/builders/browser-esbuild/builder-status-warnings.ts b/packages/angular_devkit/build_angular/src/builders/browser-esbuild/builder-status-warnings.ts deleted file mode 100644 index d5fc1342dd14..000000000000 --- a/packages/angular_devkit/build_angular/src/builders/browser-esbuild/builder-status-warnings.ts +++ /dev/null @@ -1,51 +0,0 @@ -/** - * @license - * Copyright Google LLC All Rights Reserved. - * - * Use of this source code is governed by an MIT-style license that can be - * found in the LICENSE file at https://angular.dev/license - */ - -import { BuilderContext } from '@angular-devkit/architect'; -import { Schema as BrowserBuilderOptions } from './schema'; - -const UNSUPPORTED_OPTIONS: Array = [ - // * Always enabled with esbuild - // 'commonChunk', - - // * Unused by builder and will be removed in a future release - 'vendorChunk', - 'resourcesOutputPath', - - // * Currently unsupported by esbuild - 'webWorkerTsConfig', -]; - -export function logBuilderStatusWarnings( - options: BrowserBuilderOptions, - { logger }: BuilderContext, -) { - // Validate supported options - for (const unsupportedOption of UNSUPPORTED_OPTIONS) { - const value = (options as unknown as BrowserBuilderOptions)[unsupportedOption]; - - if (value === undefined || value === false) { - continue; - } - if (Array.isArray(value) && value.length === 0) { - continue; - } - if (typeof value === 'object' && Object.keys(value).length === 0) { - continue; - } - - if (unsupportedOption === 'vendorChunk' || unsupportedOption === 'resourcesOutputPath') { - logger.warn( - `The '${unsupportedOption}' option is not used by this builder and will be ignored.`, - ); - continue; - } - - logger.warn(`The '${unsupportedOption}' option is not yet supported by this builder.`); - } -} diff --git a/packages/angular_devkit/build_angular/src/builders/browser-esbuild/index.ts b/packages/angular_devkit/build_angular/src/builders/browser-esbuild/index.ts index 6fcc8feb1535..dd91944b55b8 100644 --- a/packages/angular_devkit/build_angular/src/builders/browser-esbuild/index.ts +++ b/packages/angular_devkit/build_angular/src/builders/browser-esbuild/index.ts @@ -9,7 +9,6 @@ import { type ApplicationBuilderOptions, buildApplication } from '@angular/build'; import { BuilderContext, BuilderOutput, createBuilder } from '@angular-devkit/architect'; import type { Plugin } from 'esbuild'; -import { logBuilderStatusWarnings } from './builder-status-warnings'; import type { Schema as BrowserBuilderOptions } from './schema'; export type { BrowserBuilderOptions }; @@ -31,10 +30,25 @@ export async function* buildEsbuildBrowser( }, plugins?: Plugin[], ): AsyncIterable { - // Inform user of status of builder and options - logBuilderStatusWarnings(userOptions, context); + // Warn about any unsupported options + if (userOptions['vendorChunk']) { + context.logger.warn( + `The 'vendorChunk' option is not used by this builder and will be ignored.`, + ); + } + if (userOptions['commonChunk'] === false) { + context.logger.warn( + `The 'commonChunk' option is always enabled by this builder and will be ignored.`, + ); + } + if (userOptions['webWorkerTsConfig']) { + context.logger.warn(`The 'webWorkerTsConfig' option is not yet supported by this builder.`); + } + // Convert browser builder options to application builder options const normalizedOptions = convertBrowserOptions(userOptions); + + // Execute the application builder yield* buildApplication(normalizedOptions, context, { codePlugins: plugins }); }