From 293c767b42a820d2bae396f69b20ac795142d610 Mon Sep 17 00:00:00 2001 From: Charles Lyding <19598772+clydin@users.noreply.github.com> Date: Wed, 22 Oct 2025 10:25:32 -0400 Subject: [PATCH] refactor(@angular/cli): use command default for unspecified target builders If a target definition from a project's configuration does not contain a `builder` field and the CLI command provides a default, the default will now be used for the command execution. This is in addition to the existing case where the command will use a synthetic target definition for commands that provide default builders. --- .../src/command-builder/architect-command-module.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/packages/angular/cli/src/command-builder/architect-command-module.ts b/packages/angular/cli/src/command-builder/architect-command-module.ts index 4218c6274521..98e270cf1dad 100644 --- a/packages/angular/cli/src/command-builder/architect-command-module.ts +++ b/packages/angular/cli/src/command-builder/architect-command-module.ts @@ -41,7 +41,8 @@ export abstract class ArchitectCommandModule // Add default builder if target is not in project and a command default is provided if (this.findDefaultBuilderName && this.context.workspace) { for (const [project, projectDefinition] of this.context.workspace.projects) { - if (projectDefinition.targets.has(target)) { + const targetDefinition = projectDefinition.targets.get(target); + if (targetDefinition?.builder) { continue; } @@ -49,7 +50,13 @@ export abstract class ArchitectCommandModule project, target, }); - if (defaultBuilder) { + if (!defaultBuilder) { + continue; + } + + if (targetDefinition) { + targetDefinition.builder = defaultBuilder; + } else { projectDefinition.targets.set(target, { builder: defaultBuilder, });