Skip to content

After upgrading to Angular 13, calling scheduleBuilder fails with Error: "The builder requires a target." #22152

@Platonn

Description

@Platonn

🐞 Bug report

Command (mark with an x)

  • new
  • build
  • serve
  • test
  • e2e
  • generate
  • add
  • update
  • lint
  • extract-i18n
  • run
  • config
  • help
  • version
  • doc

Is this a regression?

Yes, the previous version in which this bug was not present was: Angular 12

Description

After upgrading to Angular 13, my custom builder that called `scheduleBuilder('@angular-devkit/build-angular:ng-packagr')` started to fail with Error: "The builder requires a target".

The reason is the commit introduced in Angular 13 5904afd , now it throws the error, when there is no target

const projectName = context.target?.project;
if (!projectName) {
throw new Error('The builder requires a target.');
}

Workaround: thanks to the another commit in Angular 13 51622bd, now I'm able to fix myself the problem and pass a new option target in the 3rd argument of scheduleBuilder() function.

The point is, it would be nice to add a schematics migration in v13 to pass the original target to the calls of scheduleBuilder. Or at least document it in the breaking changes section of the package @angular-devkit/build-angular

🔬 Minimal Reproduction

Using Angular 12, create a custom builder that calls inside: scheduleBuilder('@angular-devkit/build-angular:ng-packagr'). Then upgrade to Angular 13, run your builder and observe the build error: "The builder requires a target".

🔥 Exception or Error

"The builder requires a target"

🌍 Your Environment




Angular CLI: 13.0.1
Node: 16.13.0
Package Manager: yarn 1.22.10
OS: darwin arm64

Angular: 13.0.0
... animations, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... platform-server, router, service-worker

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1300.1
@angular-devkit/build-angular   13.0.1
@angular-devkit/core            13.0.1
@angular-devkit/schematics      13.0.1
@angular/cli                    13.0.1
@angular/pwa                    13.0.1
@nguniversal/builders           13.0.0
@nguniversal/express-engine     13.0.0
@schematics/angular             13.0.1
ng-packagr                      13.0.3
rxjs                            6.6.3
typescript                      4.4.4

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions