mirror of
https://github.com/angular/angular
synced 2026-05-24 09:28:37 +00:00
Since DevTools' Angular framework dependencies are built from local files, they are always up to date. [Recently](https://github.com/angular/angular/pull/49332) these dependencies started being published as fesm2022 instead of fesm2020. We also have an Angular dependency `ngx-flamegraph` that was built and published as fesm2020. The easiest fix to make sure all of our Angular based dependencies are processed by the linker would be to update the filterPaths field in that file from `/fesm2020/` to `/fesm2020|fesm2022/`. When v16 releases, we can update ngx-flamegraph and publish it with the new APF, letting us change filterPaths to just `/fesm2022/`. PR Close #50086
62 lines
2.8 KiB
JavaScript
62 lines
2.8 KiB
JavaScript
/**
|
|
* @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.io/license
|
|
*/
|
|
|
|
import {createEsbuildAngularOptimizePlugin} from '@angular/build-tooling/shared-scripts/angular-optimization/esbuild-plugin.mjs';
|
|
import {GLOBAL_DEFS_FOR_TERSER_WITH_AOT} from '@angular/compiler-cli/private/tooling.js';
|
|
|
|
/** Converts an object to a string dictionary. */
|
|
function convertObjectToStringDictionary(value) {
|
|
return Object.entries(value).reduce((result, [propName, value]) => {
|
|
result[propName] = String(value);
|
|
return result;
|
|
}, {});
|
|
}
|
|
|
|
export default async function createConfig({enableLinker, optimize}) {
|
|
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'],
|
|
supported: {
|
|
// Downlevel native `async/await` so that ZoneJS can intercept it.
|
|
'async-await': false,
|
|
},
|
|
define: optimize ? convertObjectToStringDictionary(GLOBAL_DEFS_FOR_TERSER_WITH_AOT) : undefined,
|
|
plugins: [
|
|
await createEsbuildAngularOptimizePlugin({
|
|
optimize: {
|
|
isSideEffectFree: null,
|
|
},
|
|
downlevelAsyncGeneratorsIfPresent: true,
|
|
enableLinker: enableLinker
|
|
? {
|
|
ensureNoPartialDeclaration: false,
|
|
// Only run the linker on fesm2020 and fesm2022 bundles. This should not have an effect on
|
|
// the bundle output, but helps speeding up ESBuild when it visits other modules.
|
|
filterPaths: /fesm2020|fesm2022/,
|
|
linkerOptions: {
|
|
// DevTools relies on angular framework packages that are consumed,
|
|
// locally via bazel. These packages have a version of 0.0.0-PLACEHOLDER.
|
|
// DevTools also relies on Angular CDK and Material packages that are consumed via npm.
|
|
// Because of this, we set unknownDeclarationVersionHandling to ignore so that we bypass
|
|
// selecting a linker for our CDK and Material dependencies based on our local framework
|
|
// version (0.0.0-PLACEHOLDER).
|
|
// Instead this option defaults to the latest linker version, which should
|
|
// be correct, except for the small time interval where we rollout a new
|
|
// declaration version and target a material release that hasn't been compiled
|
|
// with that version yet.
|
|
unknownDeclarationVersionHandling: 'ignore',
|
|
},
|
|
}
|
|
: undefined,
|
|
}),
|
|
],
|
|
};
|
|
}
|