Skip to content

Commit 42b0f16

Browse files
feat(build): Generate bundle using rollup instead of webpack
1 parent 19113ee commit 42b0f16

File tree

4 files changed

+202
-6
lines changed

4 files changed

+202
-6
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,4 @@ _doc
1616
_bundles
1717
lib
1818
lib-esm
19+
stats.html

package.json

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"scripts": {
66
"clean": "shx rm -rf lib lib-esm _bundles _dec",
77
"compile": "npm run clean && ngc",
8-
"build": "npm run compile && webpack",
8+
"build": "npm run compile && rollup -c && rollup -c --environment MINIFY",
99
"test": "karma start config/karma.ng2.js",
1010
"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",
1111
"prepublish": "npm run build"
@@ -81,6 +81,13 @@
8181
"karma-phantomjs-launcher": "^1.0.2",
8282
"karma-script-launcher": "~0.1.0",
8383
"karma-systemjs": "^0.7.2",
84+
"rollup": "^0.41.4",
85+
"rollup-plugin-commonjs": "^7.0.0",
86+
"rollup-plugin-node-resolve": "^2.0.0",
87+
"rollup-plugin-progress": "^0.2.1",
88+
"rollup-plugin-sourcemaps": "^0.4.1",
89+
"rollup-plugin-uglify": "^1.0.1",
90+
"rollup-plugin-visualizer": "^0.2.0",
8491
"rxjs": "5.0.0-beta.12",
8592
"shelljs": "^0.7.0",
8693
"shx": "^0.1.4",

rollup.config.js

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
import nodeResolve from 'rollup-plugin-node-resolve';
2+
import uglify from 'rollup-plugin-uglify';
3+
import progress from 'rollup-plugin-progress';
4+
import sourcemaps from 'rollup-plugin-sourcemaps';
5+
import visualizer from 'rollup-plugin-visualizer';
6+
import commonjs from 'rollup-plugin-commonjs';
7+
8+
var MINIFY = process.env.MINIFY;
9+
10+
var pkg = require('./package.json');
11+
var banner =
12+
`/**
13+
* ${pkg.description}
14+
* @version v${pkg.version}
15+
* @link ${pkg.homepage}
16+
* @license MIT License, http://www.opensource.org/licenses/MIT
17+
*/`;
18+
19+
var uglifyOpts = { output: {} };
20+
// retain multiline comment with @license
21+
uglifyOpts.output.comments = (node, comment) =>
22+
comment.type === 'comment2' && /@license/i.test(comment.value);
23+
24+
var plugins = [
25+
nodeResolve({jsnext: true}),
26+
progress(),
27+
sourcemaps(),
28+
commonjs(),
29+
];
30+
31+
if (MINIFY) plugins.push(uglify(uglifyOpts));
32+
if (MINIFY) plugins.push(visualizer({ sourcemap: true }));
33+
34+
var extension = MINIFY ? ".min.js" : ".js";
35+
36+
const BASE_CONFIG = {
37+
sourceMap: true,
38+
format: 'umd',
39+
exports: 'named',
40+
plugins: plugins,
41+
banner: banner,
42+
};
43+
44+
// Suppress this error message... there are hundreds of them. Angular team says to ignore it.
45+
// https://github.com/rollup/rollup/wiki/Troubleshooting#this-is-undefined
46+
function onwarn(warning) {
47+
if (warning.code === 'THIS_IS_UNDEFINED') return;
48+
console.error(warning.message);
49+
}
50+
51+
const ROUTER_CONFIG = Object.assign({
52+
moduleName: 'ui-router-ng2',
53+
entry: 'lib/index.js',
54+
dest: '_bundles/ui-router-ng2' + extension,
55+
context: 'undefined',
56+
onwarn: onwarn,
57+
external: [
58+
'rxjs',
59+
'rxjs/Rx',
60+
'rxjs/Observable',
61+
'rxjs/ReplaySubject',
62+
'rxjs/BehaviorSubject',
63+
'rxjs/Subscription',
64+
'rxjs/add/observable/of',
65+
'rxjs/add/observable/combineLatest',
66+
'rxjs/add/observable/fromPromise',
67+
'rxjs/add/operator/switchMap',
68+
'rxjs/add/operator/mergeMap',
69+
'rxjs/add/operator/concat',
70+
'rxjs/add/operator/map',
71+
'@angular/core',
72+
'@angular/common',
73+
],
74+
globals: {
75+
'@angular/core': 'ng.core',
76+
'@angular/common': 'ng.common',
77+
'rxjs/Observable': 'Rx',
78+
'rxjs/Subject': 'Rx',
79+
'rxjs/BehaviorSubject': 'Rx',
80+
'rxjs/ReplaySubject': 'Rx',
81+
}
82+
}, BASE_CONFIG);
83+
84+
export default ROUTER_CONFIG;

yarn.lock

Lines changed: 109 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ acorn@^3.1.0:
114114
version "3.3.0"
115115
resolved "https://registry.yarnpkg.com/acorn/-/acorn-3.3.0.tgz#45e37fb39e8da3f25baee3ff5369e2bb5f22017a"
116116

117-
acorn@^4.0.3, acorn@^4.0.4:
117+
acorn@^4.0.1, acorn@^4.0.3, acorn@^4.0.4:
118118
version "4.0.4"
119119
resolved "https://registry.yarnpkg.com/acorn/-/acorn-4.0.4.tgz#17a8d6a7a6c4ef538b814ec9abac2779293bf30a"
120120

@@ -275,6 +275,10 @@ asynckit@^0.4.0:
275275
version "0.4.0"
276276
resolved "https://registry.yarnpkg.com/asynckit/-/asynckit-0.4.0.tgz#c79ed97f7f34cb8f2ba1bc9790bcc366474b4b79"
277277

278+
atob@^2.0.0:
279+
version "2.0.3"
280+
resolved "https://registry.yarnpkg.com/atob/-/atob-2.0.3.tgz#19c7a760473774468f20b2d2d03372ad7d4cbf5d"
281+
278282
awesome-typescript-loader@^2.2.4:
279283
version "2.2.4"
280284
resolved "https://registry.yarnpkg.com/awesome-typescript-loader/-/awesome-typescript-loader-2.2.4.tgz#4185d60c035c25515f9c2a747fa5f69b2a001e9e"
@@ -528,6 +532,12 @@ brorand@^1.0.1:
528532
version "1.0.6"
529533
resolved "https://registry.yarnpkg.com/brorand/-/brorand-1.0.6.tgz#4028706b915f91f7b349a2e0bf3c376039d216e5"
530534

535+
browser-resolve@^1.11.0:
536+
version "1.11.2"
537+
resolved "https://registry.yarnpkg.com/browser-resolve/-/browser-resolve-1.11.2.tgz#8ff09b0a2c421718a1051c260b32e48f442938ce"
538+
dependencies:
539+
resolve "1.1.7"
540+
531541
browserify-aes@^1.0.0, browserify-aes@^1.0.4:
532542
version "1.0.6"
533543
resolved "https://registry.yarnpkg.com/browserify-aes/-/browserify-aes-1.0.6.tgz#5e7725dbdef1fd5930d4ebab48567ce451c48a0a"
@@ -595,7 +605,7 @@ buffer@^4.3.0:
595605
ieee754 "^1.1.4"
596606
isarray "^1.0.0"
597607

598-
builtin-modules@^1.0.0:
608+
builtin-modules@^1.0.0, builtin-modules@^1.1.0:
599609
version "1.1.1"
600610
resolved "https://registry.yarnpkg.com/builtin-modules/-/builtin-modules-1.1.1.tgz#270f076c5a72c02f5b65a47df94c5fe3a278892f"
601611

@@ -645,7 +655,7 @@ center-align@^0.1.1:
645655
align-text "^0.1.3"
646656
lazy-cache "^1.0.3"
647657

648-
chalk@^1.1.0, chalk@^1.1.1:
658+
chalk@^1.1.0, chalk@^1.1.1, chalk@^1.1.3:
649659
version "1.1.3"
650660
resolved "https://registry.yarnpkg.com/chalk/-/chalk-1.1.3.tgz#a8115c55e4a702fe4d150abd3872822a7e09fc98"
651661
dependencies:
@@ -1323,6 +1333,14 @@ estraverse@^1.9.1:
13231333
version "1.9.3"
13241334
resolved "https://registry.yarnpkg.com/estraverse/-/estraverse-1.9.3.tgz#af67f2dc922582415950926091a4005d29c9bb44"
13251335

1336+
estree-walker@^0.2.1:
1337+
version "0.2.1"
1338+
resolved "https://registry.yarnpkg.com/estree-walker/-/estree-walker-0.2.1.tgz#bdafe8095383d8414d5dc2ecf4c9173b6db9412e"
1339+
1340+
estree-walker@^0.3.0:
1341+
version "0.3.0"
1342+
resolved "https://registry.yarnpkg.com/estree-walker/-/estree-walker-0.3.0.tgz#f67ca8f57b9ed66d886af816c099c779b315d4db"
1343+
13261344
esutils@^2.0.2:
13271345
version "2.0.2"
13281346
resolved "https://registry.yarnpkg.com/esutils/-/esutils-2.0.2.tgz#0abf4f1caa5bcb1f7a9d8acc6dea4faaa04bac9b"
@@ -2350,6 +2368,12 @@ lru-cache@2.2.x:
23502368
version "2.2.4"
23512369
resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-2.2.4.tgz#6c658619becf14031d0d0b594b16042ce4dc063d"
23522370

2371+
magic-string@^0.19.0:
2372+
version "0.19.0"
2373+
resolved "https://registry.yarnpkg.com/magic-string/-/magic-string-0.19.0.tgz#198948217254e3e0b93080e01146b7c73b2a06b2"
2374+
dependencies:
2375+
vlq "^0.2.1"
2376+
23532377
map-obj@^1.0.0, map-obj@^1.0.1:
23542378
version "1.0.1"
23552379
resolved "https://registry.yarnpkg.com/map-obj/-/map-obj-1.0.1.tgz#d933ceb9205d82bdcf4886f6742bdc2b4dea146d"
@@ -3111,7 +3135,11 @@ requires-port@1.0.x, requires-port@1.x.x:
31113135
version "1.0.0"
31123136
resolved "https://registry.yarnpkg.com/requires-port/-/requires-port-1.0.0.tgz#925d2601d39ac485e091cf0da5c6e694dc3dcaff"
31133137

3114-
resolve@1.1.x, resolve@^1.1.6:
3138+
resolve-url@^0.2.1:
3139+
version "0.2.1"
3140+
resolved "https://registry.yarnpkg.com/resolve-url/-/resolve-url-0.2.1.tgz#2c637fe77c893afd2a663fe21aa9080068e2052a"
3141+
3142+
resolve@1.1.7, resolve@1.1.x, resolve@^1.1.6, resolve@^1.1.7:
31153143
version "1.1.7"
31163144
resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.1.7.tgz#203114d82ad2c5ed9e8e0411b3932875e889e97b"
31173145

@@ -3131,6 +3159,61 @@ ripemd160@^1.0.0:
31313159
version "1.0.1"
31323160
resolved "https://registry.yarnpkg.com/ripemd160/-/ripemd160-1.0.1.tgz#93a4bbd4942bc574b69a8fa57c71de10ecca7d6e"
31333161

3162+
rollup-plugin-commonjs@^7.0.0:
3163+
version "7.0.0"
3164+
resolved "https://registry.yarnpkg.com/rollup-plugin-commonjs/-/rollup-plugin-commonjs-7.0.0.tgz#510762d5c423c761cd16d8e8451715b39f0ceb08"
3165+
dependencies:
3166+
acorn "^4.0.1"
3167+
estree-walker "^0.3.0"
3168+
magic-string "^0.19.0"
3169+
resolve "^1.1.7"
3170+
rollup-pluginutils "^1.5.1"
3171+
3172+
rollup-plugin-node-resolve@^2.0.0:
3173+
version "2.0.0"
3174+
resolved "https://registry.yarnpkg.com/rollup-plugin-node-resolve/-/rollup-plugin-node-resolve-2.0.0.tgz#07e0ae94ac002a3ea36e8f33ca121d9f836b1309"
3175+
dependencies:
3176+
browser-resolve "^1.11.0"
3177+
builtin-modules "^1.1.0"
3178+
resolve "^1.1.6"
3179+
3180+
rollup-plugin-progress@^0.2.1:
3181+
version "0.2.1"
3182+
resolved "https://registry.yarnpkg.com/rollup-plugin-progress/-/rollup-plugin-progress-0.2.1.tgz#e3c932a0316374daaf37f471c86d4adfb9caee57"
3183+
dependencies:
3184+
chalk "^1.1.3"
3185+
rollup-pluginutils "^1.5.1"
3186+
3187+
rollup-plugin-sourcemaps@^0.4.1:
3188+
version "0.4.1"
3189+
resolved "https://registry.yarnpkg.com/rollup-plugin-sourcemaps/-/rollup-plugin-sourcemaps-0.4.1.tgz#fa7decbe012989e10d1aa6851d0c11e6d48812b7"
3190+
dependencies:
3191+
rollup-pluginutils "^1.5.0"
3192+
source-map-resolve "^0.5.0"
3193+
3194+
rollup-plugin-uglify@^1.0.1:
3195+
version "1.0.1"
3196+
resolved "https://registry.yarnpkg.com/rollup-plugin-uglify/-/rollup-plugin-uglify-1.0.1.tgz#11d0b0c8bcd2d07e6908f74fd16b0152390b922a"
3197+
dependencies:
3198+
uglify-js "^2.6.1"
3199+
3200+
rollup-plugin-visualizer@^0.2.0:
3201+
version "0.2.0"
3202+
resolved "https://registry.yarnpkg.com/rollup-plugin-visualizer/-/rollup-plugin-visualizer-0.2.0.tgz#bdd895d009144e1aab65a6caca07a7a9416e1d31"
3203+
3204+
rollup-pluginutils@^1.5.0, rollup-pluginutils@^1.5.1:
3205+
version "1.5.2"
3206+
resolved "https://registry.yarnpkg.com/rollup-pluginutils/-/rollup-pluginutils-1.5.2.tgz#1e156e778f94b7255bfa1b3d0178be8f5c552408"
3207+
dependencies:
3208+
estree-walker "^0.2.1"
3209+
minimatch "^3.0.2"
3210+
3211+
rollup@^0.41.4:
3212+
version "0.41.4"
3213+
resolved "https://registry.yarnpkg.com/rollup/-/rollup-0.41.4.tgz#a970580176329f9ead86854d7fd4c46de752aef8"
3214+
dependencies:
3215+
source-map-support "^0.4.0"
3216+
31343217
rxjs@5.0.0-beta.12:
31353218
version "5.0.0-beta.12"
31363219
resolved "https://registry.yarnpkg.com/rxjs/-/rxjs-5.0.0-beta.12.tgz#cdfde2d8c4639d20ae7794bff8fddf32da7ad337"
@@ -3309,12 +3392,25 @@ source-list-map@~0.1.7:
33093392
version "0.1.8"
33103393
resolved "https://registry.yarnpkg.com/source-list-map/-/source-list-map-0.1.8.tgz#c550b2ab5427f6b3f21f5afead88c4f5587b2106"
33113394

3395+
source-map-resolve@^0.5.0:
3396+
version "0.5.0"
3397+
resolved "https://registry.yarnpkg.com/source-map-resolve/-/source-map-resolve-0.5.0.tgz#fcad0b64b70afb27699e425950cb5ebcd410bc20"
3398+
dependencies:
3399+
atob "^2.0.0"
3400+
resolve-url "^0.2.1"
3401+
source-map-url "^0.4.0"
3402+
urix "^0.1.0"
3403+
33123404
source-map-support@^0.4.0, source-map-support@^0.4.2:
33133405
version "0.4.10"
33143406
resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.4.10.tgz#d7b19038040a14c0837a18e630a196453952b378"
33153407
dependencies:
33163408
source-map "^0.5.3"
33173409

3410+
source-map-url@^0.4.0:
3411+
version "0.4.0"
3412+
resolved "https://registry.yarnpkg.com/source-map-url/-/source-map-url-0.4.0.tgz#3e935d7ddd73631b97659956d55128e87b5084a3"
3413+
33183414
source-map@^0.4.2, source-map@^0.4.4:
33193415
version "0.4.4"
33203416
resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.4.4.tgz#eba4f5da9c0dc999de68032d8b4f76173652036b"
@@ -3665,7 +3761,7 @@ ua-parser-js@^0.7.9:
36653761
version "0.7.12"
36663762
resolved "https://registry.yarnpkg.com/ua-parser-js/-/ua-parser-js-0.7.12.tgz#04c81a99bdd5dc52263ea29d24c6bf8d4818a4bb"
36673763

3668-
uglify-js@^2.6, uglify-js@^2.7.5:
3764+
uglify-js@^2.6, uglify-js@^2.6.1, uglify-js@^2.7.5:
36693765
version "2.7.5"
36703766
resolved "https://registry.yarnpkg.com/uglify-js/-/uglify-js-2.7.5.tgz#4612c0c7baaee2ba7c487de4904ae122079f2ca8"
36713767
dependencies:
@@ -3706,6 +3802,10 @@ unpipe@1.0.0, unpipe@~1.0.0:
37063802
version "1.0.0"
37073803
resolved "https://registry.yarnpkg.com/unpipe/-/unpipe-1.0.0.tgz#b2bf4ee8514aae6165b4817829d21b2ef49904ec"
37083804

3805+
urix@^0.1.0:
3806+
version "0.1.0"
3807+
resolved "https://registry.yarnpkg.com/urix/-/urix-0.1.0.tgz#da937f7a62e21fec1fd18d49b35c2935067a6c72"
3808+
37093809
url-parse@1.0.x:
37103810
version "1.0.5"
37113811
resolved "https://registry.yarnpkg.com/url-parse/-/url-parse-1.0.5.tgz#0854860422afdcfefeb6c965c662d4800169927b"
@@ -3772,6 +3872,10 @@ verror@1.3.6:
37723872
dependencies:
37733873
extsprintf "1.0.2"
37743874

3875+
vlq@^0.2.1:
3876+
version "0.2.1"
3877+
resolved "https://registry.yarnpkg.com/vlq/-/vlq-0.2.1.tgz#14439d711891e682535467f8587c5630e4222a6c"
3878+
37753879
vm-browserify@0.0.4:
37763880
version "0.0.4"
37773881
resolved "https://registry.yarnpkg.com/vm-browserify/-/vm-browserify-0.0.4.tgz#5d7ea45bbef9e4a6ff65f95438e0a87c357d5a73"

0 commit comments

Comments
 (0)