Skip to content

build: update to Angular 20 #4778

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 13 commits into from
Jun 6, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -89,3 +89,5 @@ vitest.config.*.timestamp*
projects/www/src/app/reference/**/*.json
.nx/cache
.nx/workspace-data
.cursor/rules/nx-rules.mdc
.github/instructions/nx.instructions.md
2 changes: 1 addition & 1 deletion .node-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
20.11
22.16.0
Original file line number Diff line number Diff line change
@@ -54,6 +54,10 @@ export function findModuleFromOptions(
return normalize(modulePath + '.module.ts');
} else if (host.exists(modulePath + '/' + moduleBaseName + '.module.ts')) {
return normalize(modulePath + '/' + moduleBaseName + '.module.ts');
} else if (host.exists(modulePath + '-module.ts')) {
return normalize(modulePath + '-module.ts');
} else if (host.exists(modulePath + '/' + moduleBaseName + '-module.ts')) {
return normalize(modulePath + '/' + moduleBaseName + '-module.ts');
} else {
throw new Error(`Specified module path ${modulePath} does not exist`);
}
@@ -66,8 +70,8 @@ export function findModuleFromOptions(
export function findModule(host: Tree, generateDir: string): Path {
let dir: DirEntry | null = host.getDir('/' + generateDir);

const moduleRe = /\.module\.ts$/;
const routingModuleRe = /-routing\.module\.ts/;
const moduleRe = /(\.|-)module\.ts$/;
const routingModuleRe = /-routing(\.|-)module\.ts/;

while (dir) {
const matches = dir.subfiles.filter(
2 changes: 1 addition & 1 deletion modules/component-store/spec/integration.spec.ts
Original file line number Diff line number Diff line change
@@ -431,7 +431,7 @@ describe('ComponentStore integration', () => {
'ngOnDestroy'
);

const serviceCallSpy = jest.spyOn(TestBed.get(Service), 'call');
const serviceCallSpy = jest.spyOn(TestBed.inject(Service), 'call');
return {
...setup,
destroy: () => setup.child.propsStore.ngOnDestroy(),
13 changes: 6 additions & 7 deletions modules/component/migrations/16_0_0/index.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import * as path from 'path';
import { waitForAsync } from '@angular/core/testing';
import { Tree } from '@angular-devkit/schematics';
import {
SchematicTestRunner,
@@ -33,7 +32,7 @@ describe('Component Migration 16_0_0', () => {
},
].forEach(({ module, declarable }) => {
describe(`${module} => ${declarable}`, () => {
it(`should replace the ${module} in NgModule with ${declarable}`, waitForAsync(async () => {
it(`should replace the ${module} in NgModule with ${declarable}`, async () => {
const input = `
import { ${module} } from '@ngrx/component';

@@ -76,9 +75,9 @@ describe('Component Migration 16_0_0', () => {
const file = newTree.readContent('app.module.ts');

expect(file).toBe(expected);
}));
});

it(`should replace the ${module} in standalone component with ${declarable}`, waitForAsync(async () => {
it(`should replace the ${module} in standalone component with ${declarable}`, async () => {
const input = `
import { ${module} } from '@ngrx/component';

@@ -113,9 +112,9 @@ describe('Component Migration 16_0_0', () => {
const file = newTree.readContent('app.module.ts');

expect(file).toBe(expected);
}));
});

it(`should not remove the ${module} JS import when used as a type`, waitForAsync(async () => {
it(`should not remove the ${module} JS import when used as a type`, async () => {
const input = `
import { ${module} } from '@ngrx/component';

@@ -160,7 +159,7 @@ describe('Component Migration 16_0_0', () => {
const file = newTree.readContent('app.module.ts');

expect(file).toBe(expected);
}));
});
});
});
});
8 changes: 6 additions & 2 deletions modules/component/schematics-core/utility/find-module.ts
Original file line number Diff line number Diff line change
@@ -54,6 +54,10 @@ export function findModuleFromOptions(
return normalize(modulePath + '.module.ts');
} else if (host.exists(modulePath + '/' + moduleBaseName + '.module.ts')) {
return normalize(modulePath + '/' + moduleBaseName + '.module.ts');
} else if (host.exists(modulePath + '-module.ts')) {
return normalize(modulePath + '-module.ts');
} else if (host.exists(modulePath + '/' + moduleBaseName + '-module.ts')) {
return normalize(modulePath + '/' + moduleBaseName + '-module.ts');
} else {
throw new Error(`Specified module path ${modulePath} does not exist`);
}
@@ -66,8 +70,8 @@ export function findModuleFromOptions(
export function findModule(host: Tree, generateDir: string): Path {
let dir: DirEntry | null = host.getDir('/' + generateDir);

const moduleRe = /\.module\.ts$/;
const routingModuleRe = /-routing\.module\.ts/;
const moduleRe = /(\.|-)module\.ts$/;
const routingModuleRe = /-routing(\.|-)module\.ts/;

while (dir) {
const matches = dir.subfiles.filter(
16 changes: 0 additions & 16 deletions modules/component/spec/let/let.directive.spec.ts
Original file line number Diff line number Diff line change
@@ -3,8 +3,6 @@ import {
Component,
Directive,
ErrorHandler,
TemplateRef,
ViewContainerRef,
} from '@angular/core';
import {
ComponentFixture,
@@ -125,8 +123,6 @@ const setupLetDirectiveTestComponent = (): void => {
TestBed.configureTestingModule({
providers: [
{ provide: ChangeDetectorRef, useClass: MockChangeDetectorRef },
TemplateRef,
ViewContainerRef,
],
});
fixtureLetDirectiveTestComponent = TestBed.createComponent(
@@ -142,8 +138,6 @@ const setupLetDirectiveTestComponentError = (): void => {
providers: [
{ provide: ChangeDetectorRef, useClass: MockChangeDetectorRef },
{ provide: ErrorHandler, useClass: MockErrorHandler },
TemplateRef,
ViewContainerRef,
],
});

@@ -159,8 +153,6 @@ const setupLetDirectiveTestComponentComplete = (): void => {
TestBed.configureTestingModule({
providers: [
{ provide: ChangeDetectorRef, useClass: MockChangeDetectorRef },
TemplateRef,
ViewContainerRef,
],
});

@@ -177,8 +169,6 @@ const setupLetDirectiveTestComponentSuspense = (): void => {
providers: [
{ provide: ChangeDetectorRef, useClass: MockChangeDetectorRef },
{ provide: ErrorHandler, useClass: MockErrorHandler },
TemplateRef,
ViewContainerRef,
],
});

@@ -195,8 +185,6 @@ const setupLetDirectiveTestComponentSuspenseTpl = (): void => {
providers: [
{ provide: ChangeDetectorRef, useClass: MockChangeDetectorRef },
{ provide: ErrorHandler, useClass: MockErrorHandler },
TemplateRef,
ViewContainerRef,
],
});

@@ -213,8 +201,6 @@ const setupLetDirectiveTestRecursionComponent = (): void => {
TestBed.configureTestingModule({
providers: [
{ provide: ChangeDetectorRef, useClass: MockChangeDetectorRef },
TemplateRef,
ViewContainerRef,
{ provide: BehaviorSubject, useValue: subject },
],
});
@@ -541,8 +527,6 @@ describe('LetDirective', () => {
providers: [
{ provide: ChangeDetectorRef, useClass: MockChangeDetectorRef },
{ provide: ErrorHandler, useClass: MockErrorHandler },
TemplateRef,
ViewContainerRef,
],
});

8 changes: 6 additions & 2 deletions modules/data/schematics-core/utility/find-module.ts
Original file line number Diff line number Diff line change
@@ -54,6 +54,10 @@ export function findModuleFromOptions(
return normalize(modulePath + '.module.ts');
} else if (host.exists(modulePath + '/' + moduleBaseName + '.module.ts')) {
return normalize(modulePath + '/' + moduleBaseName + '.module.ts');
} else if (host.exists(modulePath + '-module.ts')) {
return normalize(modulePath + '-module.ts');
} else if (host.exists(modulePath + '/' + moduleBaseName + '-module.ts')) {
return normalize(modulePath + '/' + moduleBaseName + '-module.ts');
} else {
throw new Error(`Specified module path ${modulePath} does not exist`);
}
@@ -66,8 +70,8 @@ export function findModuleFromOptions(
export function findModule(host: Tree, generateDir: string): Path {
let dir: DirEntry | null = host.getDir('/' + generateDir);

const moduleRe = /\.module\.ts$/;
const routingModuleRe = /-routing\.module\.ts/;
const moduleRe = /(\.|-)module\.ts$/;
const routingModuleRe = /-routing(\.|-)module\.ts/;

while (dir) {
const matches = dir.subfiles.filter(
24 changes: 18 additions & 6 deletions modules/data/schematics/ng-add/__snapshots__/index.spec.ts.snap
Original file line number Diff line number Diff line change
@@ -1,33 +1,45 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Data ng-add Schematic Migration of ngrx-data Data ng-add Schematic for standalone application provides data without effects 1`] = `
"import { ApplicationConfig, provideZoneChangeDetection } from '@angular/core';
"import { ApplicationConfig, provideBrowserGlobalErrorListeners, provideZoneChangeDetection } from '@angular/core';
import { provideEntityData } from '@ngrx/data';
import { entityConfig } from './entity-metadata';

export const appConfig: ApplicationConfig = {
providers: [provideZoneChangeDetection({ eventCoalescing: true }), provideEntityData(entityConfig)]
providers: [
provideBrowserGlobalErrorListeners(),
provideZoneChangeDetection({ eventCoalescing: true }),
provideEntityData(entityConfig)
]
};
"
`;

exports[`Data ng-add Schematic Migration of ngrx-data Data ng-add Schematic for standalone application provides data without entityConfig 1`] = `
"import { ApplicationConfig, provideZoneChangeDetection } from '@angular/core';
"import { ApplicationConfig, provideBrowserGlobalErrorListeners, provideZoneChangeDetection } from '@angular/core';
import { provideEntityData, withEffects } from '@ngrx/data';

export const appConfig: ApplicationConfig = {
providers: [provideZoneChangeDetection({ eventCoalescing: true }), provideEntityData({}, withEffects())]
providers: [
provideBrowserGlobalErrorListeners(),
provideZoneChangeDetection({ eventCoalescing: true }),
provideEntityData({}, withEffects())
]
};
"
`;

exports[`Data ng-add Schematic Migration of ngrx-data Data ng-add Schematic for standalone application provides default data setup 1`] = `
"import { ApplicationConfig, provideZoneChangeDetection } from '@angular/core';
"import { ApplicationConfig, provideBrowserGlobalErrorListeners, provideZoneChangeDetection } from '@angular/core';
import { provideEntityData, withEffects } from '@ngrx/data';
import { entityConfig } from './entity-metadata';

export const appConfig: ApplicationConfig = {
providers: [provideZoneChangeDetection({ eventCoalescing: true }), provideEntityData(entityConfig, withEffects())]
providers: [
provideBrowserGlobalErrorListeners(),
provideZoneChangeDetection({ eventCoalescing: true }),
provideEntityData(entityConfig, withEffects())
]
};
"
`;
20 changes: 10 additions & 10 deletions modules/data/schematics/ng-add/index.spec.ts
Original file line number Diff line number Diff line change
@@ -17,7 +17,7 @@ describe('Data ng-add Schematic', () => {
const defaultOptions: DataEntityOptions = {
skipPackageJson: false,
project: 'bar',
module: 'app',
module: 'app-module',
};

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

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

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

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

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

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

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

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

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

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

8 changes: 6 additions & 2 deletions modules/effects/schematics-core/utility/find-module.ts
Original file line number Diff line number Diff line change
@@ -54,6 +54,10 @@ export function findModuleFromOptions(
return normalize(modulePath + '.module.ts');
} else if (host.exists(modulePath + '/' + moduleBaseName + '.module.ts')) {
return normalize(modulePath + '/' + moduleBaseName + '.module.ts');
} else if (host.exists(modulePath + '-module.ts')) {
return normalize(modulePath + '-module.ts');
} else if (host.exists(modulePath + '/' + moduleBaseName + '-module.ts')) {
return normalize(modulePath + '/' + moduleBaseName + '-module.ts');
} else {
throw new Error(`Specified module path ${modulePath} does not exist`);
}
@@ -66,8 +70,8 @@ export function findModuleFromOptions(
export function findModule(host: Tree, generateDir: string): Path {
let dir: DirEntry | null = host.getDir('/' + generateDir);

const moduleRe = /\.module\.ts$/;
const routingModuleRe = /-routing\.module\.ts/;
const moduleRe = /(\.|-)module\.ts$/;
const routingModuleRe = /-routing(\.|-)module\.ts/;

while (dir) {
const matches = dir.subfiles.filter(
16 changes: 12 additions & 4 deletions modules/effects/schematics/ng-add/__snapshots__/index.spec.ts.snap
Original file line number Diff line number Diff line change
@@ -1,22 +1,30 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Effects ng-add Schematic Effects ng-add Schematic for standalone application provides full effects setup 1`] = `
"import { ApplicationConfig, provideZoneChangeDetection } from '@angular/core';
"import { ApplicationConfig, provideBrowserGlobalErrorListeners, provideZoneChangeDetection } from '@angular/core';
import { provideEffects } from '@ngrx/effects';
import { FooEffects } from './foo/foo.effects';

export const appConfig: ApplicationConfig = {
providers: [provideZoneChangeDetection({ eventCoalescing: true }), provideEffects(FooEffects)]
providers: [
provideBrowserGlobalErrorListeners(),
provideZoneChangeDetection({ eventCoalescing: true }),
provideEffects(FooEffects)
]
};
"
`;

exports[`Effects ng-add Schematic Effects ng-add Schematic for standalone application provides minimal effects setup 1`] = `
"import { ApplicationConfig, provideZoneChangeDetection } from '@angular/core';
"import { ApplicationConfig, provideBrowserGlobalErrorListeners, provideZoneChangeDetection } from '@angular/core';
import { provideEffects } from '@ngrx/effects';

export const appConfig: ApplicationConfig = {
providers: [provideZoneChangeDetection({ eventCoalescing: true }), provideEffects()]
providers: [
provideBrowserGlobalErrorListeners(),
provideZoneChangeDetection({ eventCoalescing: true }),
provideEffects()
]
};
"
`;
Loading
Oops, something went wrong.