Skip to content

Commit 82a52e5

Browse files
chore(*): mark rxjs/* as external. Add prepublish to allow installs from GitHub. Fix main: in package.json.
1 parent 1aecec5 commit 82a52e5

File tree

5 files changed

+438
-177
lines changed

5 files changed

+438
-177
lines changed

package.json

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@
44
"version": "1.0.0-beta.4",
55
"scripts": {
66
"clean": "shx rm -rf lib lib-esm _bundles _doc",
7-
"build": "npm run clean && ngc && ngc -m es6 -outDir lib-esm && webpack",
7+
"build": "npm run clean && ngc && ngc -p tsconfig.esm.json && webpack",
88
"test": "karma start config/karma.ng2.js",
9-
"docs": "typedoc --tsconfig tsconfig.typedoc.json --readme README.md --name 'ui-router-ng2' --theme node_modules/ui-router-typedoc-themes/bin/default --out _doc --internal-aliases internal,coreapi,ng2api --external-aliases internalapi,external --navigation-label-globals ui-router-ng2"
9+
"docs": "typedoc --tsconfig tsconfig.typedoc.json --readme README.md --name 'ui-router-ng2' --theme node_modules/ui-router-typedoc-themes/bin/default --out _doc --internal-aliases internal,coreapi,ng2api --external-aliases internalapi,external --navigation-label-globals ui-router-ng2",
10+
"prepublish": "npm run build"
1011
},
1112
"homepage": "https://ui-router.github.io/ng2",
1213
"contributors": [
@@ -45,9 +46,9 @@
4546
"node": ">4"
4647
},
4748
"license": "MIT",
48-
"jsnext:main": "lib-esm/ng2.js",
49-
"main": "lib/ng2.js",
50-
"typings": "lib/ng2.d.ts",
49+
"jsnext:main": "lib-esm/index.js",
50+
"main": "lib/index.js",
51+
"typings": "lib/index.d.ts",
5152
"dependencies": {
5253
"ui-router-core": "=3.1.0"
5354
},
@@ -89,6 +90,7 @@
8990
"ui-router-typedoc-themes": "^1.0.0",
9091
"webpack": "1.x",
9192
"webpack-dev-server": "1.x",
93+
"webpack-visualizer-plugin": "^0.1.10",
9294
"zone.js": "^0.6.21"
9395
}
9496
}

src/index.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
/** @ng2api @module ng2 */ /** for typedoc */
22
export * from "ui-router-core";
33

4+
import "rxjs/Observable";
5+
import "rxjs/ReplaySubject";
6+
import "rxjs/BehaviorSubject";
7+
import "rxjs/Subscription";
48
import 'rxjs/add/observable/of';
59
import 'rxjs/add/observable/combineLatest';
610
import 'rxjs/add/observable/fromPromise';

tsconfig.esm.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,6 @@
1717
"strictMetadataEmit": true
1818
},
1919
"files": [
20-
"src/ng2.ts"
20+
"src/index.ts"
2121
]
2222
}

webpack.config.js

Lines changed: 33 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ var banner = pkg.description + '\n' +
55
'@license MIT License, http://www.opensource.org/licenses/MIT';
66

77
var webpack = require('webpack');
8+
var Visualizer = require('webpack-visualizer-plugin');
9+
810
module.exports = {
911
entry: {
1012
"ui-router-ng2": "./src/index.ts",
@@ -30,7 +32,8 @@ module.exports = {
3032
new webpack.optimize.UglifyJsPlugin({
3133
include: /\.min\.js$/, minimize: true
3234
}),
33-
new webpack.BannerPlugin(banner)
35+
new webpack.BannerPlugin(banner),
36+
new Visualizer(),
3437
],
3538

3639
module: {
@@ -45,9 +48,33 @@ module.exports = {
4548
}
4649
},
4750

48-
externals: {
49-
"rxjs/Rx": { root: 'rxjs/Rx', amd: 'rxjs/Rx', commonjs2: 'rxjs/Rx', commonjs: 'rxjs/Rx' },
50-
"@angular/core": { root: '@angular/core', amd: '@angular/core', commonjs2: '@angular/core', commonjs: '@angular/core' },
51-
"@angular/common": { root: '@angular/common', amd: '@angular/common', commonjs2: '@angular/common', commonjs: '@angular/common' }
52-
}
51+
externals: mkExternals([
52+
'rxjs',
53+
'rxjs/Rx',
54+
'rxjs/Observable',
55+
'rxjs/ReplaySubject',
56+
'rxjs/BehaviorSubject',
57+
'rxjs/Subscription',
58+
'rxjs/add/observable/of',
59+
'rxjs/add/observable/combineLatest',
60+
'rxjs/add/observable/fromPromise',
61+
'rxjs/add/operator/switchMap',
62+
'rxjs/add/operator/mergeMap',
63+
'rxjs/add/operator/concat',
64+
'rxjs/add/operator/map',
65+
'@angular/core',
66+
'@angular/common',
67+
])
5368
};
69+
70+
function mkExternals(names) {
71+
return names.reduce(function (acc, name) {
72+
return Object.assign(acc, mkExternal(name));
73+
}, {});
74+
}
75+
76+
function mkExternal(name) {
77+
var obj = {}
78+
obj[name] = { root: name, amd: name, commonjs2: name, commonjs: name };
79+
return obj;
80+
}

0 commit comments

Comments
 (0)