Skip to content

Commit

Permalink
feat(@schematics/angular): use @angular/build package in library ge…
Browse files Browse the repository at this point in the history
…neration schematic

The newly introduced `ng-packagr` builder within the `@angular/build` package
is now used when generating a new library with `ng generate library`. This
builder provides the same functionality as the `ng-packagr` builder found
within the `@angular-devkit/build-angular` package but removes the need for
projects to install `@angular-devkit/build-angular` if using the `application`
builder from `@angular/build`.
  • Loading branch information
clydin committed Jan 8, 2025
1 parent 2c9d736 commit 02825ee
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 6 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-devkit/build-angular',
version: latestVersions.DevkitBuildAngular,
name: '@angular/build',
version: latestVersions.AngularBuild,
},
{
type: NodeDependencyType.Dev,
Expand Down Expand Up @@ -91,7 +91,7 @@ function addLibToWorkspaceFile(
prefix: options.prefix,
targets: {
build: {
builder: Builders.NgPackagr,
builder: Builders.BuildNgPackagr,
defaultConfiguration: 'production',
options: {
project: `${projectRoot}/ng-package.json`,
Expand Down
4 changes: 1 addition & 3 deletions packages/schematics/angular/library/index_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -388,9 +388,7 @@ 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-devkit/build-angular:ng-packagr',
);
expect(workspace.projects.foo.architect.build.builder).toBe('@angular/build:ng-packagr');
});

describe('standalone=false', () => {
Expand Down
2 changes: 2 additions & 0 deletions packages/schematics/angular/utility/latest-versions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const dependencies = require('./latest-versions/package.json')['dependencies'];
export const latestVersions: Record<string, string> & {
Angular: string;
DevkitBuildAngular: string;
AngularBuild: string;
AngularSSR: string;
} = {
...dependencies,
Expand All @@ -21,5 +22,6 @@ export const latestVersions: Record<string, string> & {
Angular: dependencies['@angular/core'],

DevkitBuildAngular: '^0.0.0-PLACEHOLDER',
AngularBuild: '^0.0.0-PLACEHOLDER',
AngularSSR: '^0.0.0-PLACEHOLDER',
};
1 change: 1 addition & 0 deletions packages/schematics/angular/utility/workspace-models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export enum Builders {
Karma = '@angular-devkit/build-angular:karma',
TsLint = '@angular-devkit/build-angular:tslint',
NgPackagr = '@angular-devkit/build-angular:ng-packagr',
BuildNgPackagr = '@angular/build:ng-packagr',
DevServer = '@angular-devkit/build-angular:dev-server',
ExtractI18n = '@angular-devkit/build-angular:extract-i18n',
Protractor = '@angular-devkit/build-angular:private-protractor',
Expand Down

0 comments on commit 02825ee

Please sign in to comment.