Skip to content
This repository has been archived by the owner on Jul 27, 2018. It is now read-only.

Commit

Permalink
feat(build): Upgrade build process to emit ESM modules and a UMD bundle
Browse files Browse the repository at this point in the history
  • Loading branch information
brandonroberts committed Sep 15, 2016
1 parent 8242b1d commit 7f6c36d
Show file tree
Hide file tree
Showing 10 changed files with 124 additions and 104 deletions.
3 changes: 3 additions & 0 deletions index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export * from './src/actions';
export * from './src/reducer';
export * from './src/router-store-module';
28 changes: 20 additions & 8 deletions karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,19 @@ module.exports = function(karma) {
frameworks: ['jasmine'],

files: [
{ pattern: 'tests.ts', watched: false }
{ pattern: 'tests.bundle.ts', watched: false }
],

exclude: [],

preprocessors: {
'tests.ts': ['coverage', 'webpack', 'sourcemap']
'tests.bundle.ts': ['coverage', 'webpack', 'sourcemap']
},

reporters: ['mocha', 'coverage'],

coverageReporter: {
dir: 'coverage/',
subdir: '.',
reporters: [
{ type: 'text-summary' },
{ type: 'json' },
Expand All @@ -38,32 +37,45 @@ module.exports = function(karma) {
logLevel: karma.LOG_INFO,
autoWatch: true,
singleRun: false,

webpackServer: { noInfo: true },
webpack: {
devtool: 'inline-source-map',
resolve: {
root: __dirname,
extensions: ['', '.ts', '.js']
},
module: {
preLoaders: [
{
test: /\.ts$/,
loader: 'tslint-loader',
exclude: [
/node_modules/
]
}
],
loaders: [
{
test: /\.ts?$/,
exclude: /(node_modules)/,
loader: 'awesome-typescript'
loader: 'ts'
}
],
postLoaders: [
{
test: /\.(js|ts)$/, loader: 'istanbul-instrumenter-loader',
test: /\.(js|ts)$/, loader: 'istanbul-instrumenter',
include: path.resolve(__dirname, 'src'),
exclude: [
/\.(e2e|spec)\.ts$/,
/tests.ts$/,
/\.(e2e|spec|bundle)\.ts$/,
/node_modules/
]
}
]
},
tslint: {
emitErrors: false,
failOnHint: false,
resourcePath: 'src'
}
}
});
Expand Down
79 changes: 39 additions & 40 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,64 +2,60 @@
"name": "@ngrx/router-store",
"version": "1.2.1",
"description": "Bindings to connect angular/router to ngrx/store",
"main": "index.js",
"repository": {
"type": "git",
"url": "https://github.com/ngrx/router-store.git"
},
"main": "bundles/router-store.umd.js",
"module": "index.js",
"scripts": {
"lint": "npm-run-all lint:*",
"lint:lib": "tslint lib/**.ts",
"lint:spec": "tslint spec/**.ts",
"clean": "npm-run-all clean:*",
"clean:release": "rm -rf ./release",
"prebuild": "npm-run-all clean karma",
"build": "npm-run-all build:cjs build:esm",
"build:cjs": "ngc --p tsconfig.json",
"build:esm": "ngc -p tsconfig.esm.json",
"prepare": "npm-run-all prepare:*",
"prepare:ts": "cp -R ./src ./release",
"prepare:package": "cp ./{package.json,README.md,LICENSE} ./release",
"test": "npm-run-all clean karma",
"karma": "karma start --single-run",
"karma:watch": "karma start",
"test": "npm run karma",
"changelog": "conventional-changelog -p angular -i CHANGELOG.md -s -r 0",
"postbuild": "npm run prepare",
"preversion": "npm run test",
"clean:pre": "rimraf release",
"clean:post": "rimraf src/**/*.ngfactory.ts",
"copy": "cpy LICENSE package.json README.md release",
"build:js": "ngc -p tsconfig.dist.json",
"build:umd": "rollup -c rollup.config.js",
"build:uglify": "uglifyjs -c --screw-ie8 --comments -o ./release/bundles/router-store.min.umd.js ./release/bundles/router-store.umd.js",
"prebuild": "npm run test && npm run clean:pre",
"postbuild": "npm run clean:post && npm run copy",
"build": "npm run build:js && npm run build:umd && npm run build:uglify",
"version": "npm run changelog && git add CHANGELOG.md"
},
"repository": {
"type": "git",
"url": "https://github.com/ngrx/router-store.git"
},
"authors": [
"Mike Ryan",
"Brandon Roberts",
"Rob Wormald"
],
"license": "MIT",
"peerDependencies": {
"rxjs": "^5.0.0-beta.11",
"@angular/common": "^2.0.0-rc.6",
"@angular/core": "^2.0.0-rc.6",
"@angular/router": "^3.0.0-rc.2",
"rxjs": "^5.0.0-beta.12",
"@angular/common": "^2.0.0",
"@angular/core": "^2.0.0",
"@angular/router": "^3.0.0",
"@ngrx/core": "^1.2.0",
"@ngrx/store": "^1.5.0 || ^2.0.0"
},
"devDependencies": {
"@angular/common": "^2.0.0-rc.6",
"@angular/compiler": "^2.0.0-rc.6",
"@angular/compiler-cli": "^0.6.0",
"@angular/core": "^2.0.0-rc.6",
"@angular/platform-browser": "^2.0.0-rc.6",
"@angular/platform-browser-dynamic": "^2.0.0-rc.6",
"@angular/platform-server": "^2.0.0-rc.6",
"@angular/router": "^3.0.0-rc.2",
"@angular/tsc-wrapped": "^0.3.0",
"@ngrx/core": "^1.0.0",
"@angular/common": "^2.0.0",
"@angular/compiler": "^2.0.0",
"@angular/compiler-cli": "^0.6.1",
"@angular/core": "^2.0.0",
"@angular/platform-browser": "^2.0.0",
"@angular/platform-browser-dynamic": "^2.0.0",
"@angular/platform-server": "^2.0.0",
"@angular/router": "^3.0.0",
"@ngrx/core": "^1.2.0",
"@ngrx/store": "^2.0.0",
"@types/jasmine": "^2.2.33",
"@types/node": "^6.0.38",
"awesome-typescript-loader": "^2.2.1",
"conventional-changelog-cli": "^1.1.1",
"core-js": "^2.2.2",
"cpy-cli": "^1.0.1",
"istanbul-instrumenter-loader": "^0.2.0",
"jasmine-core": "^2.4.1",
"jasmine-core": "^2.5.0",
"karma": "^0.13.22",
"karma-chrome-launcher": "^0.2.3",
"karma-coverage": "^0.5.5",
Expand All @@ -70,11 +66,14 @@
"karma-webpack": "^1.7.0",
"npm-run-all": "^1.7.0",
"reflect-metadata": "^0.1.3",
"rxjs": "5.0.0-beta.11",
"rollup": "^0.34.13",
"rxjs": "^5.0.0-beta.12",
"source-map-loader": "^0.1.5",
"ts-loader": "^0.8.1",
"tslint": "^3.6.0",
"typescript": "^2.0.0",
"ts-loader": "^0.8.2",
"tslint": "^3.15.1",
"tslint-loader": "^2.1.5",
"typescript": "^2.0.2",
"uglifyjs": "^2.4.10",
"webpack": "^2.1.0-beta.21",
"zone.js": "^0.6.17"
}
Expand Down
15 changes: 15 additions & 0 deletions rollup.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
export default {
entry: './release/index.js',
dest: './release/bundles/router-store.umd.js',
format: 'umd',
moduleName: 'ngrx.routerStore',
globals: {
'rxjs/Observable': 'Rx',
'rxjs/Subscriber': 'Rx',
'rxjs/operator/distinctUntilChanged': 'Rx.Observable.prototype',
'rxjs/operator/do': 'Rx.Observable.prototype',
'rxjs/operator/filter': 'Rx.Observable.prototype',
'rxjs/operator/map': 'Rx.Observable.prototype',
'@ngrx/core': 'ngrx.core'
}
}
7 changes: 3 additions & 4 deletions src/connect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@ import 'rxjs/add/operator/filter';
import 'rxjs/add/operator/distinctUntilChanged';
import 'rxjs/add/operator/map';
import 'rxjs/add/operator/withLatestFrom';
import '@ngrx/core/add/operator/select';
import { Router, Event, NavigationEnd, UrlTree } from '@angular/router';
import { Location } from '@angular/common';
import { Store, Action } from '@ngrx/store';
import { Observable } from 'rxjs/Observable';
import { Observer } from 'rxjs/Observer';
import { select } from '@ngrx/core';

import { RouterMethodCall, routerActions, routerActionTypes } from './actions';

Expand All @@ -25,7 +24,7 @@ export function listenForRouterMethodActions(router: Router, location: Location,
break;

case routerActions.REPLACE:
router.navigate(commands, Object.assign({}, extras, <any>({ queryParams, replaceUrl: true })));
router.navigate(commands, Object.assign({}, extras, { queryParams, replaceUrl: true }));
break;

case routerActions.SEARCH:
Expand All @@ -50,7 +49,7 @@ export function listenForRouterMethodActions(router: Router, location: Location,
}

export function selectRouter(store: Store<any>) {
return store.select(state => state.router);
return select.call(store, (state) => state.router);
}

export function getLatestUrl(router: Router): Observable<string> {
Expand Down
18 changes: 0 additions & 18 deletions src/index.ts

This file was deleted.

File renamed without changes.
26 changes: 26 additions & 0 deletions tsconfig.dist.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@

{
"compilerOptions": {
"baseUrl": ".",
"declaration": true,
"stripInternal": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"module": "es2015",
"moduleResolution": "node",
"noEmitOnError": false,
"outDir": "./release",
"rootDir": ".",
"sourceMap": true,
"inlineSources": true,
"lib": ["es2015", "dom"],
"target": "es5",
"skipLibCheck": true
},
"files": [
"index.ts"
],
"angularCompilerOptions": {
"strictMetadataEmit": true
}
}
22 changes: 0 additions & 22 deletions tsconfig.esm.json

This file was deleted.

30 changes: 18 additions & 12 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,22 +1,28 @@

{
"version": "2.0.0",
"compileOnSave": false,
"compilerOptions": {
"outDir": "./release",
"target": "es5",
"module": "commonjs",
"sourceMap": false,
"baseUrl": ".",
"declaration": true,
"stripInternal": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"removeComments": false,
"module": "commonjs",
"moduleResolution": "node",
"declaration": true,
"lib": ["dom", "es5", "es2015"]
"noEmitOnError": false,
"outDir": "./release",
"rootDir": ".",
"lib": ["es2015", "dom"],
"target": "es5",
"skipLibCheck": true,
"types": [
"node",
"jasmine"
]
},
"include": [
"src/**/*.ts"
"exclude": [
"node_modules"
],
"angularCompilerOptions": {
"genDir": ".ngc"
"strictMetadataEmit": true
}
}

0 comments on commit 7f6c36d

Please sign in to comment.