Skip to content
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

build: update to Angular 15 rc #3630

Merged
merged 2 commits into from
Oct 24, 2022
Merged
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ version: 2.1
var_1: &cache_key yarn-cache-{{ checksum "yarn.lock" }}-0.14.1
var_2: &run_in_node
docker:
- image: cimg/node:14.17.0
- image: cimg/node:14.20.0
var_5: &run_in_browser
docker:
- image: cimg/node:14.17.0-browsers
- image: cimg/node:14.20.0-browsers

orbs:
browser-tools: circleci/browser-tools@1.3.0
Expand Down
2 changes: 1 addition & 1 deletion .node-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
14.17
14.20
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Angular v15 suports Node v14.20 or higher. I also updated "engines" in package.json to be the same as in the Angular repo.

7 changes: 4 additions & 3 deletions modules/component-store/tsconfig.build.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"declaration": true,
"stripInternal": true,
"experimentalDecorators": true,
"module": "es2015",
"module": "ES2022",
"moduleResolution": "node",
"noEmitOnError": false,
"noImplicitAny": true,
Expand All @@ -15,8 +15,9 @@
"rootDir": ".",
"sourceMap": true,
"inlineSources": true,
"lib": ["es2018", "dom"],
"target": "es2020",
"lib": ["ES2022", "dom"],
"target": "ES2022",
"useDefineForClassFields": false,
"skipLibCheck": true
},
"files": ["public_api.ts"],
Expand Down
7 changes: 4 additions & 3 deletions modules/component/tsconfig.build.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"experimentalDecorators": true,
"strictPropertyInitialization": true,
"strictNullChecks": true,
"module": "es2015",
"module": "ES2022",
"moduleResolution": "node",
"noEmitOnError": false,
"noImplicitAny": true,
Expand All @@ -17,8 +17,9 @@
"rootDir": ".",
"sourceMap": true,
"inlineSources": true,
"lib": ["es2015", "dom"],
"target": "es2020",
"lib": ["ES2022", "dom"],
"target": "ES2022",
"useDefineForClassFields": false,
"skipLibCheck": true
},
"files": ["public_api.ts"],
Expand Down
7 changes: 4 additions & 3 deletions modules/data/tsconfig.build.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"declaration": true,
"stripInternal": true,
"experimentalDecorators": true,
"module": "es2015",
"module": "ES2022",
"moduleResolution": "node",
"noEmitOnError": false,
"noImplicitAny": true,
Expand All @@ -15,8 +15,9 @@
"rootDir": ".",
"sourceMap": true,
"inlineSources": true,
"lib": ["es2018", "dom"],
"target": "es2020",
"lib": ["ES2022", "dom"],
"target": "ES2022",
"useDefineForClassFields": false,
"skipLibCheck": true
},
"files": ["public_api.ts"],
Expand Down
29 changes: 13 additions & 16 deletions modules/effects/spec/provide_effects.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ describe('provideEffects', () => {
multi: true,
useValue: () => jest.spyOn(inject(EffectsRunner), 'start'),
},
provideStore({}).ɵproviders,
provideStore(),
// provide effects twice
provideEffects().ɵproviders,
provideEffects().ɵproviders,
provideEffects(),
provideEffects(),
],
});

Expand All @@ -48,10 +48,10 @@ describe('provideEffects', () => {
multi: true,
useValue: () => jest.spyOn(inject(Store), 'dispatch'),
},
provideStore().ɵproviders,
provideStore(),
// provide effects twice
provideEffects().ɵproviders,
provideEffects().ɵproviders,
provideEffects(),
provideEffects(),
],
});

Expand All @@ -63,18 +63,15 @@ describe('provideEffects', () => {
it('throws an error when store is not provided', () => {
TestBed.configureTestingModule({
// provide only effects
providers: [provideEffects(TestEffects).ɵproviders],
providers: [provideEffects(TestEffects)],
});

expect(() => TestBed.inject(TestEffects)).toThrowError();
});

it('runs provided effects', (done) => {
TestBed.configureTestingModule({
providers: [
provideStore().ɵproviders,
provideEffects(TestEffects).ɵproviders,
],
providers: [provideStore(), provideEffects(TestEffects)],
});

const store = TestBed.inject(Store);
Expand All @@ -91,9 +88,9 @@ describe('provideEffects', () => {
it('runs provided effects after root state registration', (done) => {
TestBed.configureTestingModule({
providers: [
provideEffects(TestEffects).ɵproviders,
provideEffects(TestEffects),
// provide store after effects
provideStore({ [rootSliceKey]: createReducer('ngrx') }).ɵproviders,
provideStore({ [rootSliceKey]: createReducer('ngrx') }),
],
});

Expand All @@ -113,10 +110,10 @@ describe('provideEffects', () => {
it('runs provided effects after feature state registration', (done) => {
TestBed.configureTestingModule({
providers: [
provideStore().ɵproviders,
provideEffects(TestEffects).ɵproviders,
provideStore(),
provideEffects(TestEffects),
// provide feature state after effects
provideState(featureSliceKey, createReducer('effects')).ɵproviders,
provideState(featureSliceKey, createReducer('effects')),
],
});

Expand Down
57 changes: 30 additions & 27 deletions modules/effects/src/provide_effects.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import { ENVIRONMENT_INITIALIZER, inject, Type } from '@angular/core';
import {
ENVIRONMENT_INITIALIZER,
EnvironmentProviders,
inject,
makeEnvironmentProviders,
Type,
} from '@angular/core';
import {
FEATURE_STATE_PROVIDER,
ROOT_STORE_PROVIDER,
Store,
Expand Down Expand Up @@ -41,35 +46,33 @@ import { rootEffectsInit as effectsInit } from './effects_actions';
export function provideEffects(
...effects: Type<unknown>[]
): EnvironmentProviders {
return {
ɵproviders: [
effects,
{
provide: ENVIRONMENT_INITIALIZER,
multi: true,
useValue: () => {
inject(ROOT_STORE_PROVIDER);
inject(FEATURE_STATE_PROVIDER, { optional: true });
return makeEnvironmentProviders([
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Angular v15 now exports the EnvironmentProviders type, also there is the makeEnvironmentProviders function that converts providers array to environment providers.

effects,
{
provide: ENVIRONMENT_INITIALIZER,
multi: true,
useValue: () => {
inject(ROOT_STORE_PROVIDER);
inject(FEATURE_STATE_PROVIDER, { optional: true });

const effectsRunner = inject(EffectsRunner);
const effectSources = inject(EffectSources);
const shouldInitEffects = !effectsRunner.isStarted;
const effectsRunner = inject(EffectsRunner);
const effectSources = inject(EffectSources);
const shouldInitEffects = !effectsRunner.isStarted;

if (shouldInitEffects) {
effectsRunner.start();
}
if (shouldInitEffects) {
effectsRunner.start();
}

for (const effectsClass of effects) {
const effectsInstance = inject(effectsClass);
effectSources.addEffects(effectsInstance);
}
for (const effectsClass of effects) {
const effectsInstance = inject(effectsClass);
effectSources.addEffects(effectsInstance);
}

if (shouldInitEffects) {
const store = inject(Store);
store.dispatch(effectsInit());
}
},
if (shouldInitEffects) {
const store = inject(Store);
store.dispatch(effectsInit());
}
},
],
};
},
]);
}
7 changes: 4 additions & 3 deletions modules/effects/tsconfig.build.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"declaration": true,
"stripInternal": true,
"experimentalDecorators": true,
"module": "es2015",
"module": "ES2022",
"moduleResolution": "node",
"noEmitOnError": false,
"noImplicitAny": true,
Expand All @@ -15,8 +15,9 @@
"rootDir": ".",
"sourceMap": true,
"inlineSources": true,
"lib": ["es2018", "dom"],
"target": "es2020",
"lib": ["ES2022", "dom"],
"target": "ES2022",
"useDefineForClassFields": false,
"skipLibCheck": true
},
"files": ["public_api.ts"],
Expand Down
7 changes: 4 additions & 3 deletions modules/entity/tsconfig.build.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"declaration": true,
"stripInternal": true,
"experimentalDecorators": true,
"module": "es2015",
"module": "ES2022",
"moduleResolution": "node",
"noEmitOnError": false,
"noImplicitAny": true,
Expand All @@ -15,8 +15,9 @@
"rootDir": ".",
"sourceMap": true,
"inlineSources": true,
"lib": ["es2018", "dom"],
"target": "es2020",
"lib": ["ES2022", "dom"],
"target": "ES2022",
"useDefineForClassFields": false,
"skipLibCheck": true
},
"files": ["public_api.ts"],
Expand Down
56 changes: 29 additions & 27 deletions modules/router-store/src/provide_router_store.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
import { ENVIRONMENT_INITIALIZER, inject } from '@angular/core';
import {
ENVIRONMENT_INITIALIZER,
EnvironmentProviders,
inject,
makeEnvironmentProviders,
} from '@angular/core';
import {
_createRouterConfig,
_ROUTER_CONFIG,
Expand All @@ -16,7 +21,6 @@ import {
RouterStateSerializer,
} from './serializers/base';
import { StoreRouterConnectingService } from './store_router_connecting.service';
import { EnvironmentProviders } from '@ngrx/store';

/**
* Connects the Angular Router to the Store.
Expand All @@ -35,30 +39,28 @@ import { EnvironmentProviders } from '@ngrx/store';
export function provideRouterStore<
T extends BaseRouterStoreState = SerializedRouterStateSnapshot
>(config: StoreRouterConfig<T> = {}): EnvironmentProviders {
return {
ɵproviders: [
{ provide: _ROUTER_CONFIG, useValue: config },
{
provide: ROUTER_CONFIG,
useFactory: _createRouterConfig,
deps: [_ROUTER_CONFIG],
},
{
provide: RouterStateSerializer,
useClass: config.serializer
? config.serializer
: config.routerState === RouterState.Full
? FullRouterStateSerializer
: MinimalRouterStateSerializer,
},
{
provide: ENVIRONMENT_INITIALIZER,
multi: true,
useFactory() {
return () => inject(StoreRouterConnectingService);
},
return makeEnvironmentProviders([
{ provide: _ROUTER_CONFIG, useValue: config },
{
provide: ROUTER_CONFIG,
useFactory: _createRouterConfig,
deps: [_ROUTER_CONFIG],
},
{
provide: RouterStateSerializer,
useClass: config.serializer
? config.serializer
: config.routerState === RouterState.Full
? FullRouterStateSerializer
: MinimalRouterStateSerializer,
},
{
provide: ENVIRONMENT_INITIALIZER,
multi: true,
useFactory() {
return () => inject(StoreRouterConnectingService);
},
StoreRouterConnectingService,
],
};
},
StoreRouterConnectingService,
]);
}
2 changes: 1 addition & 1 deletion modules/router-store/src/router_store_module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export class StoreRouterConnectingModule {
): ModuleWithProviders<StoreRouterConnectingModule> {
return {
ngModule: StoreRouterConnectingModule,
providers: [...provideRouterStore(config).ɵproviders],
providers: [provideRouterStore(config)],
};
}
}
1 change: 1 addition & 0 deletions modules/router-store/src/serializers/full_serializer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export class FullRouterStateSerializer
data: route.data,
url: route.url,
outlet: route.outlet,
title: route.title,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In v15, title is required property

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤔

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

*title is required property in ActivatedRouteSnapshot class, not Route interface 😅

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahh ok. I was worried there for a minute 😄

routeConfig: route.routeConfig
? {
component: route.routeConfig.component,
Expand Down
7 changes: 4 additions & 3 deletions modules/router-store/tsconfig.build.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"declaration": true,
"stripInternal": true,
"experimentalDecorators": true,
"module": "es2015",
"module": "ES2022",
"moduleResolution": "node",
"noEmitOnError": false,
"noImplicitAny": true,
Expand All @@ -15,8 +15,9 @@
"rootDir": ".",
"sourceMap": true,
"inlineSources": true,
"lib": ["es2018", "dom"],
"target": "es2020",
"lib": ["ES2022", "dom"],
"target": "ES2022",
"useDefineForClassFields": false,
"skipLibCheck": true
},
"files": ["public_api.ts"],
Expand Down
2 changes: 1 addition & 1 deletion modules/schematics/src/container/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ describe('Container Schematic', () => {
`${projectPath}/src/app/foo/foo.component.ts`
);

expect(content).toMatch(/constructor\(private store: Store\) { }\n\n/);
expect(content).toMatch(/constructor\(private store: Store\) {}\n/);
});

it('should update the component spec', async () => {
Expand Down
Loading