Skip to content

Commit 8d50abc

Browse files
author
Angular Builds
committed
f263306 refactor(@angular/build): make buildTarget optional in unit-test builder
1 parent 6f5bb03 commit 8d50abc

File tree

6 files changed

+20
-13
lines changed

6 files changed

+20
-13
lines changed

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@angular/build",
3-
"version": "21.0.0-next.5+sha-3b7dabb",
3+
"version": "21.0.0-next.5+sha-f263306",
44
"description": "Official build system for Angular",
55
"keywords": [
66
"Angular CLI",
@@ -23,7 +23,7 @@
2323
"builders": "builders.json",
2424
"dependencies": {
2525
"@ampproject/remapping": "2.3.0",
26-
"@angular-devkit/architect": "github:angular/angular-devkit-architect-builds#3b7dabb",
26+
"@angular-devkit/architect": "github:angular/angular-devkit-architect-builds#f263306",
2727
"@babel/core": "7.28.4",
2828
"@babel/helper-annotate-as-pure": "7.27.3",
2929
"@babel/helper-split-export-declaration": "7.24.7",
@@ -60,7 +60,7 @@
6060
"@angular/platform-browser": "^21.0.0-next.0",
6161
"@angular/platform-server": "^21.0.0-next.0",
6262
"@angular/service-worker": "^21.0.0-next.0",
63-
"@angular/ssr": "github:angular/angular-ssr-builds#3b7dabb",
63+
"@angular/ssr": "github:angular/angular-ssr-builds#f263306",
6464
"karma": "^6.4.0",
6565
"less": "^4.2.0",
6666
"ng-packagr": "^21.0.0-next.0",

src/builders/unit-test/builder.js

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,15 @@ async function* execute(options, context, extensions) {
266266
// Get base build options from the buildTarget
267267
let buildTargetOptions;
268268
try {
269-
buildTargetOptions = (await context.validateOptions(await context.getTargetOptions(normalizedOptions.buildTarget), await context.getBuilderNameForTarget(normalizedOptions.buildTarget)));
269+
const builderName = await context.getBuilderNameForTarget(normalizedOptions.buildTarget);
270+
if (builderName !== '@angular/build:application' &&
271+
// TODO: Add comprehensive support for ng-packagr.
272+
builderName !== '@angular/build:ng-packagr') {
273+
context.logger.warn(`The 'buildTarget' is configured to use '${builderName}', which is not supported. ` +
274+
`The 'unit-test' builder is designed to work with '@angular/build:application'. ` +
275+
'Unexpected behavior or build failures may occur.');
276+
}
277+
buildTargetOptions = (await context.validateOptions(await context.getTargetOptions(normalizedOptions.buildTarget), builderName));
270278
}
271279
catch (e) {
272280
(0, error_1.assertIsError)(e);
@@ -304,10 +312,8 @@ async function* execute(options, context, extensions) {
304312
...runnerBuildOptions,
305313
watch: normalizedOptions.watch,
306314
progress: normalizedOptions.buildProgress ?? buildTargetOptions.progress,
315+
...(normalizedOptions.tsConfig ? { tsConfig: normalizedOptions.tsConfig } : {}),
307316
};
308-
if (normalizedOptions.tsConfig) {
309-
applicationBuildOptions.tsConfig = normalizedOptions.tsConfig;
310-
}
311317
const dumpDirectory = normalizedOptions.dumpVirtualFiles
312318
? node_path_1.default.join(normalizedOptions.cacheOptions.path, 'unit-test', 'output-files')
313319
: undefined;

src/builders/unit-test/schema.d.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,11 @@ export type Schema = {
1010
browsers?: string[];
1111
/**
1212
* Specifies the build target to use for the unit test build in the format
13-
* `project:target[:configuration]`. You can also pass a comma-separated list of
13+
* `project:target[:configuration]`. This defaults to the `build` target of the current
14+
* project with the `development` configuration. You can also pass a comma-separated list of
1415
* configurations. Example: `project:target:production,staging`.
1516
*/
16-
buildTarget: string;
17+
buildTarget?: string;
1718
/**
1819
* Enables coverage reporting for tests.
1920
*/

src/builders/unit-test/schema.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"properties": {
77
"buildTarget": {
88
"type": "string",
9-
"description": "Specifies the build target to use for the unit test build in the format `project:target[:configuration]`. You can also pass a comma-separated list of configurations. Example: `project:target:production,staging`.",
9+
"description": "Specifies the build target to use for the unit test build in the format `project:target[:configuration]`. This defaults to the `build` target of the current project with the `development` configuration. You can also pass a comma-separated list of configurations. Example: `project:target:production,staging`.",
1010
"pattern": "^[^:\\s]*:[^:\\s]*(:[^\\s]+)?$"
1111
},
1212
"tsConfig": {
@@ -262,5 +262,5 @@
262262
}
263263
},
264264
"additionalProperties": false,
265-
"required": ["buildTarget", "runner"]
265+
"required": ["runner"]
266266
}

src/utils/normalize-cache.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
1010
exports.normalizeCacheOptions = normalizeCacheOptions;
1111
const node_path_1 = require("node:path");
1212
/** Version placeholder is replaced during the build process with actual package version */
13-
const VERSION = '21.0.0-next.5+sha-3b7dabb';
13+
const VERSION = '21.0.0-next.5+sha-f263306';
1414
function hasCacheMetadata(value) {
1515
return (!!value &&
1616
typeof value === 'object' &&

uniqueId

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Thu Oct 02 2025 17:11:43 GMT+0000 (Coordinated Universal Time)
1+
Thu Oct 02 2025 18:25:45 GMT+0000 (Coordinated Universal Time)

0 commit comments

Comments
 (0)