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

test(integration): angular 5.2 + typescript 2.7 #852

Merged
merged 20 commits into from
Feb 26, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
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
16 changes: 16 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,15 @@ jobs:
command: yarn test:ci:integration:ssr
# - *persist_coverage // we don't run code coverage for integration tests

integration_ng5_tests:
<<: *job_defaults
steps:
- *attach_workspace
- run:
name: Integration Tests
command: yarn run integration:ng5
# - *persist_coverage // we don't run code coverage for integration tests

upload_coverage:
<<: *job_defaults
environment:
Expand Down Expand Up @@ -189,11 +198,16 @@ workflows:
requires:
- build

- integration_ng5_tests:
requires:
- build

- upload_coverage:
requires:
- unit_tests
- integration_tests
- integration_ssr_tests
- integration_ng5_tests

# Publish @dev builds if no tag is specified
- publish_dev_build_to_npm:
Expand All @@ -207,6 +221,7 @@ workflows:
- unit_tests
- integration_tests
- integration_ssr_tests
- integration_ng5_tests

# Publish package.version @latest when a v.* git tag is present
- publish_tagged_build_to_npm:
Expand All @@ -219,3 +234,4 @@ workflows:
- unit_tests
- integration_tests
- integration_ssr_tests
- integration_ng5_tests
16 changes: 12 additions & 4 deletions integrations/hello-world-ng5/.angular-cli.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,20 @@
"apps": [
{
"root": "src",
"prefix": "app",
"outDir": "dist",
"main": "main.ts",
"index": "index.html",
"main": "main.ts",
"polyfills": "polyfills.ts",
"tsconfig": "tsconfig.app.json",
"environmentSource": "environments/environment.ts"
"prefix": "app",
"environmentSource": "environments/environment.ts",
"environments": {
"dev": "environments/environment.ts",
"prod": "environments/environment.prod.ts"
}
}
]
],
"warnings": {
"typescriptMismatch": false
}
}
13 changes: 8 additions & 5 deletions integrations/hello-world-ng5/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@
"license": "MIT",
"scripts": {
"ng": "ng",
"npx": "npx",
"test": "npm install @ngxs/store && npx -- ng build"
"start": "ng serve --hmr",
"test": "ng build",
"pretest": "npm install",
"postinstall": "cpx -v -C \"../../@ngxs/**/*\" \"node_modules/@ngxs/\""
},
"private": true,
"dependencies": {
Expand All @@ -18,9 +20,9 @@
"@angular/platform-browser": "5.2.0",
"@angular/platform-browser-dynamic": "5.2.0",
"@angular/router": "5.2.0",
"@ngxs/store": "^3.3.4",
"core-js": "2.4.1",
"rxjs": "5.5.6",
"rxjs": "5.6.0-forward-compat.4",
"rxjs-compat": "6.2.2",
"zone.js": "0.8.19"
},
"devDependencies": {
Expand All @@ -31,6 +33,7 @@
"@types/jasminewd2": "2.0.2",
"@types/node": "6.0.60",
"codelyzer": "4.0.1",
"cpx": "^1.5.0",
"jasmine-core": "2.8.0",
"jasmine-spec-reporter": "4.2.1",
"karma": "2.0.0",
Expand All @@ -42,6 +45,6 @@
"protractor": "5.1.2",
"ts-node": "4.1.0",
"tslint": "5.9.1",
"typescript": "2.5.3"
"typescript": "2.7.1"
}
}
9 changes: 5 additions & 4 deletions integrations/hello-world-ng5/src/app/app.module.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';

import { StoreModule } from './store.module';
import { AppComponent } from './app.component';
// import { NgxsModule } from '@ngxs/store';

const routes: Routes = [{ path: '', component: AppComponent }];

@NgModule({
declarations: [AppComponent],
// fix me after they add support
// imports: [BrowserModule, NgxsModule.forRoot([])],
imports: [BrowserModule],
imports: [BrowserModule, RouterModule.forRoot(routes), StoreModule],
bootstrap: [AppComponent]
})
export class AppModule {}
7 changes: 7 additions & 0 deletions integrations/hello-world-ng5/src/app/app.state.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { State } from '@ngxs/store';

@State<string[]>({
name: 'app',
defaults: []
})
export class AppState {}
24 changes: 24 additions & 0 deletions integrations/hello-world-ng5/src/app/store.module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { NgModule } from '@angular/core';
import { NgxsModule } from '@ngxs/store';
import { NgxsReduxDevtoolsPluginModule } from '@ngxs/devtools-plugin';
import { NgxsFormPluginModule } from '@ngxs/form-plugin';
import { NgxsLoggerPluginModule } from '@ngxs/logger-plugin';
import { NgxsStoragePluginModule } from '@ngxs/storage-plugin';
import { NgxsWebsocketPluginModule } from '@ngxs/websocket-plugin';
import { NgxsRouterPluginModule } from '@ngxs/router-plugin';

import { AppState } from './app.state';

@NgModule({
imports: [
NgxsModule.forRoot([AppState]),
NgxsReduxDevtoolsPluginModule.forRoot(),
NgxsFormPluginModule.forRoot(),
NgxsLoggerPluginModule.forRoot(),
NgxsStoragePluginModule.forRoot(),
NgxsWebsocketPluginModule.forRoot(),
NgxsRouterPluginModule.forRoot()
],
exports: [NgxsModule]
})
export class StoreModule {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export const environment = {
production: true,
hmr: false
};
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export const environment = {
production: true
production: false,
hmr: true
};
18 changes: 15 additions & 3 deletions integrations/hello-world-ng5/src/main.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,25 @@
import { enableProdMode } from '@angular/core';
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { BootstrapModuleFn, hmr, WebpackModule } from '@ngxs/hmr-plugin';

import { AppModule } from './app/app.module';
import { environment } from './environments/environment';

declare const module: WebpackModule;

if (environment.production) {
enableProdMode();
}

platformBrowserDynamic()
.bootstrapModule(AppModule)
.catch(err => console.log(err));
const bootstrap: BootstrapModuleFn = () => platformBrowserDynamic().bootstrapModule(AppModule);

if (environment.hmr) {
if (module['hot']) {
hmr(module, bootstrap).catch(err => console.error(err));
} else {
console.error('HMR is not enabled for webpack-dev-server!');
console.log('Are you using the --hmr flag for ng serve?');
}
} else {
bootstrap().catch(err => console.log(err));
}
1 change: 1 addition & 0 deletions integrations/hello-world-ng5/src/polyfills.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import 'zone.js/dist/zone';
14 changes: 6 additions & 8 deletions integrations/hello-world-ng5/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,16 @@
"compileOnSave": false,
"compilerOptions": {
"outDir": "./dist/out-tsc",
"baseUrl": "./",
"sourceMap": true,
"declaration": false,
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"target": "es5",
"typeRoots": [
"node_modules/@types"
],
"lib": [
"es2017",
"dom"
]
}
"paths": {},
"typeRoots": ["node_modules/@types"],
"lib": ["es2017", "dom"]
},
"exclude": ["node_modules"]
}
5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,7 @@
"docs": "typedoc packages/store/src --options typedoc.json",
"format": "prettier --write \"{packages,integration}/**/*.ts\"",
"// - INTEGRATION": "Integration builds",
"integration:link": "cd @ngxs && npm link && cd ..",
"integration:ng5": "npm run integration:link && cd integrations/hello-world-ng5 && npm install && npm test"
"integration:ng5": "cd integrations/hello-world-ng5 && npm test"
},
"private": true,
"devDependencies": {
Expand Down Expand Up @@ -133,7 +132,7 @@
"lint-staged": "^8.0.0",
"mocha": "^6.0.0",
"mock-socket": "^8.0.5",
"ng-packagr": "^4.4.5",
"ng-packagr": "^4.7.1",
"npm-delay": "^1.0.4",
"npm-run-all": "^4.1.2",
"prettier": "1.15.3",
Expand Down
8 changes: 7 additions & 1 deletion packages/hmr-plugin/src/public_api.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
export { NgxsHmrLifeCycle, NgxsHmrOptions, NgxsHmrSnapshot } from './symbols';
export { HmrInitAction } from './actions/hmr-init.action';
export {
NgxsHmrLifeCycle,
NgxsHmrOptions,
NgxsHmrSnapshot,
WebpackModule,
BootstrapModuleFn
Copy link
Member

Choose a reason for hiding this comment

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

Why have WebpackModule and BootstrapModuleFn been added to the exports?
Was something not working? It works fine in my app without this.

Copy link
Member Author

Choose a reason for hiding this comment

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

no, it works without, I just wanted to use the types in the example, the user may also want this

} from './symbols';
export { HmrBeforeDestroyAction } from './actions/hmr-before-destroy.action';
export { hmr } from './hmr-bootstrap';
2 changes: 1 addition & 1 deletion packages/hmr-plugin/src/symbols.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export interface NgxsHmrLifeCycle<T = NgxsHmrSnapshot> {
}

export type HmrCallback<T> = (ctx: StateContext<T>, state: Partial<T>) => void;
export type BootstrapModuleFn<T> = () => Promise<NgModuleRef<T>>;
export type BootstrapModuleFn<T = any> = () => Promise<NgModuleRef<T>>;

export interface NgxsHmrOptions {
/**
Expand Down
10 changes: 5 additions & 5 deletions packages/router-plugin/src/router.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ import { NgxsModule } from '@ngxs/store';
import { DefaultRouterStateSerializer, RouterStateSerializer } from './serializer';
import { RouterState } from './router.state';

// NOTE: Must mark as `dynamic` due to
// https://github.com/dherges/ng-packagr/issues/767
export const NgxsModuleRouterState = NgxsModule.forFeature([RouterState]);

// @dynamic
@NgModule({
imports: [NgxsModuleRouterState],
imports: [
// NOTE: Must mark as `dynamic` due to
// https://github.com/dherges/ng-packagr/issues/767
NgxsModule.forFeature([RouterState])
],
providers: [{ provide: RouterStateSerializer, useClass: DefaultRouterStateSerializer }]
})
export class NgxsRouterPluginModule {
Expand Down
3 changes: 2 additions & 1 deletion packages/router-plugin/src/router.state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
RouterNavigation
} from './router.actions';
import { RouterStateSerializer } from './serializer';
import { NgZone } from '@angular/core';
import { NgZone, Injectable } from '@angular/core';

export type RouterStateModel<T = RouterStateSnapshot> = {
state?: T;
Expand All @@ -30,6 +30,7 @@ export type RouterStateModel<T = RouterStateSnapshot> = {
navigationId: undefined
}
})
@Injectable()
export class RouterState {
private routerStateSnapshot: RouterStateSnapshot;
private routerState: RouterStateModel;
Expand Down
Loading