mirror of
https://github.com/angular/angular
synced 2026-05-24 09:28:37 +00:00
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.
54 lines
1.9 KiB
JavaScript
54 lines
1.9 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
|
|
*/
|
|
|
|
/**
|
|
* Karma configuration that is used by Bazel karma_web_test targets which do not
|
|
* want to launch any browser and just enable manual browser debugging.
|
|
*/
|
|
|
|
module.exports = config => {
|
|
const overwrites = {};
|
|
|
|
// By default "@bazel/concatjs" configures Chrome as browser. Since we don't want
|
|
// to launch any browser at all, we overwrite the "browsers" option. Since the
|
|
// default config tries to extend the browsers array with "Chrome", we need to
|
|
// always return a new empty array.
|
|
Object.defineProperty(overwrites, 'browsers', {
|
|
get: () => [],
|
|
set: () => {},
|
|
enumerable: true,
|
|
});
|
|
|
|
// Ensures that tests start executing once browsers have been manually connected. We need
|
|
// to use "defineProperty" because the default "@bazel/concatjs" config overwrites the option.
|
|
Object.defineProperty(overwrites, 'autoWatch', {
|
|
get: () => true,
|
|
set: () => {},
|
|
enumerable: true,
|
|
});
|
|
|
|
// When not running with ibazel, do not set up the `@bazel/concatjs` watcher. This one
|
|
// relies on ibazel to write to the `stdin` interface. When running without ibazel, the
|
|
// watcher will kill concatjs since there is no data written to the `stdin` interface.
|
|
if (process.env['IBAZEL_NOTIFY_CHANGES'] !== 'y') {
|
|
// We pre-define a plugins array that captures registration of Karma plugins
|
|
// and unsets the watcher definitions so that no watcher can be configured.
|
|
overwrites.plugins = new KarmaPluginArrayWithoutWatchers();
|
|
}
|
|
|
|
config.set(overwrites);
|
|
};
|
|
|
|
class KarmaPluginArrayWithoutWatchers extends Array {
|
|
// The Bazel Karma rules only register new plugins using `.push`.
|
|
push(...plugins) {
|
|
plugins.filter(p => typeof p === 'object').forEach(p => delete p.watcher);
|
|
|
|
super.push(...plugins);
|
|
}
|
|
}
|