angular/devtools/tools/esbuild/esbuild-spec.config.mjs
AleksanderBodurri 445fbf81fd refactor(devtools): bring the angular devtools directory into the root bazel workspace
Previously devtools used a nested workspace for its bazel configurations. This meant framework dependencies were consumed via npm.

Now devtools is part of the root bazel directory that all other files in this codebase fall under. This allows us to build devtools using local angular packages, removing the need to consume these dependencies with npn. This is useful because we no longer have to update these dependencies with an automated tool like renovate, and our CI tests will always run against the most up to date framework packages.
2022-01-26 16:35:31 -05:00

51 lines
2.1 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 baseEsbuildConfig from './esbuild-base.config.mjs';
/**
* Loads and creates the ESBuild linker plugin.
*
* The plugin is not loaded at top-level as not all spec bundle targets rely
* on the linker and this would slow-down bundling.
*/
async function fetchAndCreateLinkerEsbuildPlugin() {
// Note: This needs to be a NPM module path as this ESBuild config is generated and can
// end up in arbitrary Bazel packages or differently-named consumer workspaces.
const {createLinkerEsbuildPlugin} = await import(
'@angular/dev-infra-private/shared-scripts/angular-linker/esbuild-plugin.mjs'
);
return await createLinkerEsbuildPlugin(
/.*/,
/* ensureNoPartialDeclaration */ true,
// 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' }
);
}
// Based on the Bazel action and its substitutions, we run the linker for all inputs.
const plugins = [await fetchAndCreateLinkerEsbuildPlugin()];
export default {
...baseEsbuildConfig,
// Use the `iife` format for the test entry-point as tests should run immediately.
// For browser tests which are wrapped in an AMD header and footer, this works as well.
format: 'iife',
plugins,
};