Skip to content

Commit 08bc4df

Browse files
alan-agius4mgechev
authored andcommitted
feat(@schematics/angular): add migration ensure that tslib is installed (#15800)
Related to: angular/angular#32167
1 parent 0d70565 commit 08bc4df

File tree

3 files changed

+26
-3
lines changed

3 files changed

+26
-3
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/**
2+
* @license
3+
* Copyright Google Inc. All Rights Reserved.
4+
*
5+
* Use of this source code is governed by an MIT-style license that can be
6+
* found in the LICENSE file at https://angular.io/license
7+
*/
8+
import { Rule } from '@angular-devkit/schematics';
9+
import { NodeDependencyType, addPackageJsonDependency, removePackageJsonDependency } from '../../utility/dependencies';
10+
import { latestVersions } from '../../utility/latest-versions';
11+
12+
export function addTsLib(): Rule {
13+
return host => {
14+
removePackageJsonDependency(host, 'tslib');
15+
addPackageJsonDependency(host, {
16+
name: 'tslib',
17+
version: latestVersions.TsLib,
18+
type: NodeDependencyType.Default,
19+
});
20+
};
21+
}

packages/schematics/angular/migrations/update-9/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
import { Rule, chain } from '@angular-devkit/schematics';
1010
import { NodePackageInstallTask } from '@angular-devkit/schematics/tasks';
11+
import { addTsLib } from './add-tslib';
1112
import { updateLibraries } from './ivy-libraries';
1213
import { updateNGSWConfig } from './ngsw-config';
1314
import { removeTsickle } from './remove-tsickle';
@@ -26,6 +27,7 @@ export default function(): Rule {
2627
updateDependencies(),
2728
updateServerMainFile(),
2829
removeTsickle(),
30+
addTsLib(),
2931
(tree, context) => {
3032
const packageChanges = tree.actions.some(a => a.path.endsWith('/package.json'));
3133
if (packageChanges) {

packages/schematics/angular/migrations/update-9/update-dependencies.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@
55
* Use of this source code is governed by an MIT-style license that can be
66
* found in the LICENSE file at https://angular.io/license
77
*/
8-
import { Tree } from '@angular-devkit/schematics';
8+
import { Rule } from '@angular-devkit/schematics';
99
import { addPackageJsonDependency, getPackageJsonDependency } from '../../utility/dependencies';
1010
import { latestVersions } from '../../utility/latest-versions';
1111

12-
export function updateDependencies() {
13-
return (host: Tree) => {
12+
export function updateDependencies(): Rule {
13+
return host => {
1414
const dependenciesToUpdate: Record<string, string> = {
1515
'@angular/pwa': latestVersions.AngularPWA,
1616
'@angular-devkit/build-angular': latestVersions.DevkitBuildAngular,

0 commit comments

Comments
 (0)