Skip to content

Commit

Permalink
fix(@schematics/angular): update library schematic to use `@angular-d…
Browse files Browse the repository at this point in the history
…evkit/build-angular:ng-packagr`

The library schematic currently relies on Karma, which requires `@angular-devkit/build-angular` to be installed. To address this, we now use the `ng-packagr` builder provided in this package.

Closes #29494

(cherry picked from commit cae068b)
  • Loading branch information
alan-agius4 committed Jan 29, 2025
1 parent 3cc197c commit 14e3a71
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
6 changes: 3 additions & 3 deletions packages/schematics/angular/library/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ function addDependenciesToPackageJson() {
},
{
type: NodeDependencyType.Dev,
name: '@angular/build',
version: latestVersions.AngularBuild,
name: '@angular-devkit/build-angular',
version: latestVersions.DevkitBuildAngular,
},
{
type: NodeDependencyType.Dev,
Expand Down Expand Up @@ -91,7 +91,7 @@ function addLibToWorkspaceFile(
prefix: options.prefix,
targets: {
build: {
builder: Builders.BuildNgPackagr,
builder: Builders.NgPackagr,
defaultConfiguration: 'production',
options: {
project: `${projectRoot}/ng-package.json`,
Expand Down
4 changes: 3 additions & 1 deletion packages/schematics/angular/library/index_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,9 @@ describe('Library Schematic', () => {
const tree = await schematicRunner.runSchematic('library', defaultOptions, workspaceTree);

const workspace = JSON.parse(tree.readContent('/angular.json'));
expect(workspace.projects.foo.architect.build.builder).toBe('@angular/build:ng-packagr');
expect(workspace.projects.foo.architect.build.builder).toBe(
'@angular-devkit/build-angular:ng-packagr',
);
});

describe('standalone=false', () => {
Expand Down

0 comments on commit 14e3a71

Please sign in to comment.