Skip to content

Commit c716ce1

Browse files
committed
fix(@schematics/angular): skip ssr migration when @angular/ssr is not a dependency
This commit updates the `update-ssr-imports` migration to not run when the @angular/ssr` package is not listed as a dependency. Closes #29560
1 parent c48a2da commit c716ce1

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

packages/schematics/angular/migrations/update-ssr-imports/migration.ts

+5
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
import { DirEntry, Rule, UpdateRecorder } from '@angular-devkit/schematics';
1010
import * as ts from '../../third_party/github.com/Microsoft/TypeScript/lib/typescript';
11+
import { getPackageJsonDependency } from '../../utility/dependencies';
1112

1213
function* visit(directory: DirEntry): IterableIterator<ts.SourceFile> {
1314
for (const path of directory.subfiles) {
@@ -46,6 +47,10 @@ function* visit(directory: DirEntry): IterableIterator<ts.SourceFile> {
4647
*/
4748
export default function (): Rule {
4849
return (tree) => {
50+
if (!getPackageJsonDependency(tree, '@angular/ssr')) {
51+
return;
52+
}
53+
4954
for (const sourceFile of visit(tree.root)) {
5055
let recorder: UpdateRecorder | undefined;
5156

packages/schematics/angular/migrations/update-ssr-imports/migration_spec.ts

+8
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,14 @@ describe('CommonEngine migration', () => {
1919
let tree: UnitTestTree;
2020
beforeEach(() => {
2121
tree = new UnitTestTree(new EmptyTree());
22+
tree.create(
23+
'package.json',
24+
JSON.stringify({
25+
dependencies: {
26+
'@angular/ssr': '0.0.0',
27+
},
28+
}),
29+
);
2230
});
2331

2432
function runMigration(): Promise<UnitTestTree> {

0 commit comments

Comments
 (0)