mirror of
https://github.com/angular/angular-cli.git
synced 2025-05-22 06:41:45 +08:00
In 10.1, `@angular-devkit/build-ng-packagr` was deprecated in favor of `@angular-devkit/build-angular`. This migration updates the library build target to use the non deprecated builder.
37 lines
1.2 KiB
TypeScript
37 lines
1.2 KiB
TypeScript
/**
|
|
* @license
|
|
* Copyright Google Inc. All Rights Reserved.
|
|
*
|
|
* Use of this source code is governed by an MIT-style license that can be
|
|
* found in the LICENSE file at https://angular.io/license
|
|
*/
|
|
|
|
import { Rule, chain } from '@angular-devkit/schematics';
|
|
import { NodeDependencyType, addPackageJsonDependency, removePackageJsonDependency } from '../../utility/dependencies';
|
|
import { latestVersions } from '../../utility/latest-versions';
|
|
import { updateWorkspace } from '../../utility/workspace';
|
|
import { Builders } from '../../utility/workspace-models';
|
|
|
|
export default function (): Rule {
|
|
return chain([
|
|
updateWorkspace(workspace => {
|
|
for (const [, project] of workspace.projects) {
|
|
for (const [, target] of project.targets) {
|
|
if (target.builder === Builders.DeprecatedNgPackagr) {
|
|
target.builder = Builders.NgPackagr;
|
|
}
|
|
}
|
|
}
|
|
}),
|
|
host => {
|
|
removePackageJsonDependency(host, '@angular-devkit/build-ng-packagr');
|
|
addPackageJsonDependency(host, {
|
|
type: NodeDependencyType.Dev,
|
|
name: '@angular-devkit/build-angular',
|
|
version: latestVersions.DevkitBuildAngular,
|
|
overwrite: false,
|
|
});
|
|
},
|
|
]);
|
|
}
|