/
githubmirror
/
angular
Обзор
Документация
Войти
/
githubmirror
/
angular
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
devtools/tools/esbuild/esbuild-base.config.mts
47 строк
1 KB
Alan Agius
refactor(devtools): use JavaScriptTransformer for Angular optimization esbuild plugin
07 авг 2026, 20:30
07 авг 2026, 20:30
cf1844b
Код
Авторство
О чём код?
/** * @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 */ // @ts-ignore import {createEsbuildAngularOptimizePlugin} from '../angular-optimization/esbuild-plugin.mjs'; import {GLOBAL_DEFS_FOR_TERSER_WITH_AOT} from '@angular/compiler-cli/private/tooling'; /** Converts an object to a string dictionary. */ function convertObjectToStringDictionary(value: {[key: string]: any}) { return Object.entries(value).reduce( (result, [propName, value]) => { result[propName] = String(value); return result; }, {} as {[key: string]: string}, ); } export default async function createConfig({ enableLinker, optimize, }: { enableLinker: boolean; optimize: boolean; }) { return { resolveExtensions: ['.mjs', '.js'], // This ensures that we prioritize ES2020. RxJS would otherwise use the ESM5 output. mainFields: ['es2020', 'es2015', 'module', 'main'], // `tslib` sets the `module` condition to resolve to ESM. conditions: ['es2020', 'es2015', 'module'], define: optimize ? convertObjectToStringDictionary(GLOBAL_DEFS_FOR_TERSER_WITH_AOT) : undefined, plugins: [ createEsbuildAngularOptimizePlugin({ optimize: { isSideEffectFree: undefined, }, enableLinker, }), ], }; }