Skip to content

Commit 8a4ecd9

Browse files
build: update to Angular 20 (#4778)
BREAKING CHANGES: The minimum required version of Angular has been updated. BEFORE: The minimum required version is Angular 19.x AFTER: The minimum required version is Angular 20.x
1 parent 4397bfb commit 8a4ecd9

File tree

70 files changed

+3618
-3156
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+3618
-3156
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,3 +89,5 @@ vitest.config.*.timestamp*
8989
projects/www/src/app/reference/**/*.json
9090
.nx/cache
9191
.nx/workspace-data
92+
.cursor/rules/nx-rules.mdc
93+
.github/instructions/nx.instructions.md

.node-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
20.11
1+
22.16.0

modules/component-store/schematics-core/utility/find-module.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,10 @@ export function findModuleFromOptions(
5454
return normalize(modulePath + '.module.ts');
5555
} else if (host.exists(modulePath + '/' + moduleBaseName + '.module.ts')) {
5656
return normalize(modulePath + '/' + moduleBaseName + '.module.ts');
57+
} else if (host.exists(modulePath + '-module.ts')) {
58+
return normalize(modulePath + '-module.ts');
59+
} else if (host.exists(modulePath + '/' + moduleBaseName + '-module.ts')) {
60+
return normalize(modulePath + '/' + moduleBaseName + '-module.ts');
5761
} else {
5862
throw new Error(`Specified module path ${modulePath} does not exist`);
5963
}
@@ -66,8 +70,8 @@ export function findModuleFromOptions(
6670
export function findModule(host: Tree, generateDir: string): Path {
6771
let dir: DirEntry | null = host.getDir('/' + generateDir);
6872

69-
const moduleRe = /\.module\.ts$/;
70-
const routingModuleRe = /-routing\.module\.ts/;
73+
const moduleRe = /(\.|-)module\.ts$/;
74+
const routingModuleRe = /-routing(\.|-)module\.ts/;
7175

7276
while (dir) {
7377
const matches = dir.subfiles.filter(

modules/component-store/spec/integration.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,7 @@ describe('ComponentStore integration', () => {
431431
'ngOnDestroy'
432432
);
433433

434-
const serviceCallSpy = jest.spyOn(TestBed.get(Service), 'call');
434+
const serviceCallSpy = jest.spyOn(TestBed.inject(Service), 'call');
435435
return {
436436
...setup,
437437
destroy: () => setup.child.propsStore.ngOnDestroy(),

modules/component/migrations/16_0_0/index.spec.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import * as path from 'path';
2-
import { waitForAsync } from '@angular/core/testing';
32
import { Tree } from '@angular-devkit/schematics';
43
import {
54
SchematicTestRunner,
@@ -33,7 +32,7 @@ describe('Component Migration 16_0_0', () => {
3332
},
3433
].forEach(({ module, declarable }) => {
3534
describe(`${module} => ${declarable}`, () => {
36-
it(`should replace the ${module} in NgModule with ${declarable}`, waitForAsync(async () => {
35+
it(`should replace the ${module} in NgModule with ${declarable}`, async () => {
3736
const input = `
3837
import { ${module} } from '@ngrx/component';
3938
@@ -76,9 +75,9 @@ describe('Component Migration 16_0_0', () => {
7675
const file = newTree.readContent('app.module.ts');
7776

7877
expect(file).toBe(expected);
79-
}));
78+
});
8079

81-
it(`should replace the ${module} in standalone component with ${declarable}`, waitForAsync(async () => {
80+
it(`should replace the ${module} in standalone component with ${declarable}`, async () => {
8281
const input = `
8382
import { ${module} } from '@ngrx/component';
8483
@@ -113,9 +112,9 @@ describe('Component Migration 16_0_0', () => {
113112
const file = newTree.readContent('app.module.ts');
114113

115114
expect(file).toBe(expected);
116-
}));
115+
});
117116

118-
it(`should not remove the ${module} JS import when used as a type`, waitForAsync(async () => {
117+
it(`should not remove the ${module} JS import when used as a type`, async () => {
119118
const input = `
120119
import { ${module} } from '@ngrx/component';
121120
@@ -160,7 +159,7 @@ describe('Component Migration 16_0_0', () => {
160159
const file = newTree.readContent('app.module.ts');
161160

162161
expect(file).toBe(expected);
163-
}));
162+
});
164163
});
165164
});
166165
});

modules/component/schematics-core/utility/find-module.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,10 @@ export function findModuleFromOptions(
5454
return normalize(modulePath + '.module.ts');
5555
} else if (host.exists(modulePath + '/' + moduleBaseName + '.module.ts')) {
5656
return normalize(modulePath + '/' + moduleBaseName + '.module.ts');
57+
} else if (host.exists(modulePath + '-module.ts')) {
58+
return normalize(modulePath + '-module.ts');
59+
} else if (host.exists(modulePath + '/' + moduleBaseName + '-module.ts')) {
60+
return normalize(modulePath + '/' + moduleBaseName + '-module.ts');
5761
} else {
5862
throw new Error(`Specified module path ${modulePath} does not exist`);
5963
}
@@ -66,8 +70,8 @@ export function findModuleFromOptions(
6670
export function findModule(host: Tree, generateDir: string): Path {
6771
let dir: DirEntry | null = host.getDir('/' + generateDir);
6872

69-
const moduleRe = /\.module\.ts$/;
70-
const routingModuleRe = /-routing\.module\.ts/;
73+
const moduleRe = /(\.|-)module\.ts$/;
74+
const routingModuleRe = /-routing(\.|-)module\.ts/;
7175

7276
while (dir) {
7377
const matches = dir.subfiles.filter(

modules/component/spec/let/let.directive.spec.ts

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ import {
33
Component,
44
Directive,
55
ErrorHandler,
6-
TemplateRef,
7-
ViewContainerRef,
86
} from '@angular/core';
97
import {
108
ComponentFixture,
@@ -125,8 +123,6 @@ const setupLetDirectiveTestComponent = (): void => {
125123
TestBed.configureTestingModule({
126124
providers: [
127125
{ provide: ChangeDetectorRef, useClass: MockChangeDetectorRef },
128-
TemplateRef,
129-
ViewContainerRef,
130126
],
131127
});
132128
fixtureLetDirectiveTestComponent = TestBed.createComponent(
@@ -142,8 +138,6 @@ const setupLetDirectiveTestComponentError = (): void => {
142138
providers: [
143139
{ provide: ChangeDetectorRef, useClass: MockChangeDetectorRef },
144140
{ provide: ErrorHandler, useClass: MockErrorHandler },
145-
TemplateRef,
146-
ViewContainerRef,
147141
],
148142
});
149143

@@ -159,8 +153,6 @@ const setupLetDirectiveTestComponentComplete = (): void => {
159153
TestBed.configureTestingModule({
160154
providers: [
161155
{ provide: ChangeDetectorRef, useClass: MockChangeDetectorRef },
162-
TemplateRef,
163-
ViewContainerRef,
164156
],
165157
});
166158

@@ -177,8 +169,6 @@ const setupLetDirectiveTestComponentSuspense = (): void => {
177169
providers: [
178170
{ provide: ChangeDetectorRef, useClass: MockChangeDetectorRef },
179171
{ provide: ErrorHandler, useClass: MockErrorHandler },
180-
TemplateRef,
181-
ViewContainerRef,
182172
],
183173
});
184174

@@ -195,8 +185,6 @@ const setupLetDirectiveTestComponentSuspenseTpl = (): void => {
195185
providers: [
196186
{ provide: ChangeDetectorRef, useClass: MockChangeDetectorRef },
197187
{ provide: ErrorHandler, useClass: MockErrorHandler },
198-
TemplateRef,
199-
ViewContainerRef,
200188
],
201189
});
202190

@@ -213,8 +201,6 @@ const setupLetDirectiveTestRecursionComponent = (): void => {
213201
TestBed.configureTestingModule({
214202
providers: [
215203
{ provide: ChangeDetectorRef, useClass: MockChangeDetectorRef },
216-
TemplateRef,
217-
ViewContainerRef,
218204
{ provide: BehaviorSubject, useValue: subject },
219205
],
220206
});
@@ -541,8 +527,6 @@ describe('LetDirective', () => {
541527
providers: [
542528
{ provide: ChangeDetectorRef, useClass: MockChangeDetectorRef },
543529
{ provide: ErrorHandler, useClass: MockErrorHandler },
544-
TemplateRef,
545-
ViewContainerRef,
546530
],
547531
});
548532

modules/data/schematics-core/utility/find-module.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,10 @@ export function findModuleFromOptions(
5454
return normalize(modulePath + '.module.ts');
5555
} else if (host.exists(modulePath + '/' + moduleBaseName + '.module.ts')) {
5656
return normalize(modulePath + '/' + moduleBaseName + '.module.ts');
57+
} else if (host.exists(modulePath + '-module.ts')) {
58+
return normalize(modulePath + '-module.ts');
59+
} else if (host.exists(modulePath + '/' + moduleBaseName + '-module.ts')) {
60+
return normalize(modulePath + '/' + moduleBaseName + '-module.ts');
5761
} else {
5862
throw new Error(`Specified module path ${modulePath} does not exist`);
5963
}
@@ -66,8 +70,8 @@ export function findModuleFromOptions(
6670
export function findModule(host: Tree, generateDir: string): Path {
6771
let dir: DirEntry | null = host.getDir('/' + generateDir);
6872

69-
const moduleRe = /\.module\.ts$/;
70-
const routingModuleRe = /-routing\.module\.ts/;
73+
const moduleRe = /(\.|-)module\.ts$/;
74+
const routingModuleRe = /-routing(\.|-)module\.ts/;
7175

7276
while (dir) {
7377
const matches = dir.subfiles.filter(
Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,45 @@
11
// Jest Snapshot v1, https://goo.gl/fbAQLP
22

33
exports[`Data ng-add Schematic Migration of ngrx-data Data ng-add Schematic for standalone application provides data without effects 1`] = `
4-
"import { ApplicationConfig, provideZoneChangeDetection } from '@angular/core';
4+
"import { ApplicationConfig, provideBrowserGlobalErrorListeners, provideZoneChangeDetection } from '@angular/core';
55
import { provideEntityData } from '@ngrx/data';
66
import { entityConfig } from './entity-metadata';
77
88
export const appConfig: ApplicationConfig = {
9-
providers: [provideZoneChangeDetection({ eventCoalescing: true }), provideEntityData(entityConfig)]
9+
providers: [
10+
provideBrowserGlobalErrorListeners(),
11+
provideZoneChangeDetection({ eventCoalescing: true }),
12+
provideEntityData(entityConfig)
13+
]
1014
};
1115
"
1216
`;
1317

1418
exports[`Data ng-add Schematic Migration of ngrx-data Data ng-add Schematic for standalone application provides data without entityConfig 1`] = `
15-
"import { ApplicationConfig, provideZoneChangeDetection } from '@angular/core';
19+
"import { ApplicationConfig, provideBrowserGlobalErrorListeners, provideZoneChangeDetection } from '@angular/core';
1620
import { provideEntityData, withEffects } from '@ngrx/data';
1721
1822
export const appConfig: ApplicationConfig = {
19-
providers: [provideZoneChangeDetection({ eventCoalescing: true }), provideEntityData({}, withEffects())]
23+
providers: [
24+
provideBrowserGlobalErrorListeners(),
25+
provideZoneChangeDetection({ eventCoalescing: true }),
26+
provideEntityData({}, withEffects())
27+
]
2028
};
2129
"
2230
`;
2331

2432
exports[`Data ng-add Schematic Migration of ngrx-data Data ng-add Schematic for standalone application provides default data setup 1`] = `
25-
"import { ApplicationConfig, provideZoneChangeDetection } from '@angular/core';
33+
"import { ApplicationConfig, provideBrowserGlobalErrorListeners, provideZoneChangeDetection } from '@angular/core';
2634
import { provideEntityData, withEffects } from '@ngrx/data';
2735
import { entityConfig } from './entity-metadata';
2836
2937
export const appConfig: ApplicationConfig = {
30-
providers: [provideZoneChangeDetection({ eventCoalescing: true }), provideEntityData(entityConfig, withEffects())]
38+
providers: [
39+
provideBrowserGlobalErrorListeners(),
40+
provideZoneChangeDetection({ eventCoalescing: true }),
41+
provideEntityData(entityConfig, withEffects())
42+
]
3143
};
3244
"
3345
`;

modules/data/schematics/ng-add/index.spec.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ describe('Data ng-add Schematic', () => {
1717
const defaultOptions: DataEntityOptions = {
1818
skipPackageJson: false,
1919
project: 'bar',
20-
module: 'app',
20+
module: 'app-module',
2121
};
2222

2323
const projectPath = getTestProjectPath();
@@ -47,17 +47,17 @@ describe('Data ng-add Schematic', () => {
4747
});
4848

4949
it('should import into a specified module', async () => {
50-
const options = { ...defaultOptions, module: 'app.module.ts' };
50+
const options = { ...defaultOptions, module: 'app-module.ts' };
5151

5252
const tree = await schematicRunner.runSchematic('ng-add', options, appTree);
53-
const content = tree.readContent(`${projectPath}/src/app/app.module.ts`);
53+
const content = tree.readContent(`${projectPath}/src/app/app-module.ts`);
5454
expect(content).toMatch(/import { EntityDataModule } from '@ngrx\/data'/);
5555
});
5656

5757
it('should fail if specified module does not exist', async () => {
5858
const options = {
5959
...defaultOptions,
60-
module: `${projectPath}/src/app/app.moduleXXX.ts`,
60+
module: `${projectPath}/src/app/app-moduleXXX.ts`,
6161
};
6262
let thrownError: Error | null = null;
6363
try {
@@ -72,7 +72,7 @@ describe('Data ng-add Schematic', () => {
7272
const options = { ...defaultOptions, effects: false, entityConfig: true };
7373

7474
const tree = await schematicRunner.runSchematic('ng-add', options, appTree);
75-
const content = tree.readContent(`${projectPath}/src/app/app.module.ts`);
75+
const content = tree.readContent(`${projectPath}/src/app/app-module.ts`);
7676
expect(content).toMatch(
7777
/import { entityConfig } from '.\/entity-metadata'/
7878
);
@@ -94,7 +94,7 @@ describe('Data ng-add Schematic', () => {
9494
const options = { ...defaultOptions, entityConfig: true };
9595

9696
const tree = await schematicRunner.runSchematic('ng-add', options, appTree);
97-
const content = tree.readContent(`${projectPath}/src/app/app.module.ts`);
97+
const content = tree.readContent(`${projectPath}/src/app/app-module.ts`);
9898
expect(content).toMatch(
9999
/import { entityConfig } from '.\/entity-metadata'/
100100
);
@@ -104,13 +104,13 @@ describe('Data ng-add Schematic', () => {
104104
it('should import EntityDataModuleWithoutEffects into a specified module', async () => {
105105
const options = {
106106
...defaultOptions,
107-
module: 'app.module.ts',
107+
module: 'app-module.ts',
108108
effects: false,
109109
entityConfig: false,
110110
};
111111

112112
const tree = await schematicRunner.runSchematic('ng-add', options, appTree);
113-
const content = tree.readContent(`${projectPath}/src/app/app.module.ts`);
113+
const content = tree.readContent(`${projectPath}/src/app/app-module.ts`);
114114
expect(content).toMatch(
115115
/import { EntityDataModuleWithoutEffects } from '@ngrx\/data'/
116116
);
@@ -120,15 +120,15 @@ describe('Data ng-add Schematic', () => {
120120
const options = { ...defaultOptions, entityConfig: false };
121121

122122
const tree = await schematicRunner.runSchematic('ng-add', options, appTree);
123-
const content = tree.readContent(`${projectPath}/src/app/app.module.ts`);
123+
const content = tree.readContent(`${projectPath}/src/app/app-module.ts`);
124124
expect(content).toMatch(/EntityDataModule/);
125125
});
126126

127127
it('should register EntityDataModuleWithoutEffects in the provided module', async () => {
128128
const options = { ...defaultOptions, effects: false, entityConfig: false };
129129

130130
const tree = await schematicRunner.runSchematic('ng-add', options, appTree);
131-
const content = tree.readContent(`${projectPath}/src/app/app.module.ts`);
131+
const content = tree.readContent(`${projectPath}/src/app/app-module.ts`);
132132
expect(content).toMatch(/EntityDataModuleWithoutEffects/);
133133
});
134134

0 commit comments

Comments
 (0)