/
githubmirror
/
angular-cli
Обзор
Документация
Войти
/
githubmirror
/
angular-cli
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
packages/angular_devkit/build_angular/src/builders/browser-esbuild/index.ts
87 строк
3 KB
Alan Agius
refactor(@angular-devkit/build-angular): deprecate Webpack builders
06 май 2026, 19:48
06 май 2026, 19:48
b7940db
Код
Авторство
О чём код?
/** * @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 { type ApplicationBuilderOptions, buildApplication } from '@angular/build'; import { BuilderContext, BuilderOutput, createBuilder } from '@angular-devkit/architect'; import type { Plugin } from 'esbuild'; import type { Schema as BrowserBuilderOptions } from './schema'; export type { BrowserBuilderOptions }; type OutputPathClass = Exclude<ApplicationBuilderOptions['outputPath'], string | undefined>; /** * Main execution function for the esbuild-based application builder. * The options are compatible with the Webpack-based builder. * @param userOptions The browser builder options to use when setting up the application build * @param context The Architect builder context object * @returns An async iterable with the builder result output */ export async function* buildEsbuildBrowser( userOptions: BrowserBuilderOptions, context: BuilderContext, infrastructureSettings?: { write?: boolean; }, plugins?: Plugin[], ): AsyncIterable<BuilderOutput> { context.logger.warn( 'The "@angular-devkit/build-angular:browser-esbuild" builder is deprecated as part of Angular\'s Webpack support deprecation. ' + 'Use "@angular/build:application" instead. For more information, see https://angular.dev/tools/cli/build-system-migration.', ); // 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 }); } export function convertBrowserOptions( options: BrowserBuilderOptions, ): Omit<ApplicationBuilderOptions, 'outputPath'> & { outputPath: OutputPathClass } { const { main: browser, outputPath, ngswConfigPath, serviceWorker, polyfills, resourcesOutputPath, ...otherOptions } = options; return { browser, serviceWorker: serviceWorker ? ngswConfigPath : false, polyfills: typeof polyfills === 'string' ? [polyfills] : polyfills, outputPath: { base: outputPath, browser: '', server: '', media: resourcesOutputPath ?? 'media', }, ...otherOptions, }; } export default createBuilder<BrowserBuilderOptions>(buildEsbuildBrowser);