@@ -5,23 +5,23 @@ import sourcemaps from 'rollup-plugin-sourcemaps';
5
5
import visualizer from 'rollup-plugin-visualizer' ;
6
6
import commonjs from 'rollup-plugin-commonjs' ;
7
7
8
- var MINIFY = process . env . MINIFY ;
8
+ let MINIFY = process . env . MINIFY ;
9
9
10
- var pkg = require ( './package.json' ) ;
11
- var banner =
10
+ let pkg = require ( './package.json' ) ;
11
+ let banner =
12
12
`/**
13
13
* ${ pkg . description }
14
14
* @version v${ pkg . version }
15
15
* @link ${ pkg . homepage }
16
16
* @license MIT License, http://www.opensource.org/licenses/MIT
17
17
*/` ;
18
18
19
- var uglifyOpts = { output : { } } ;
19
+ let uglifyOpts = { output : { } } ;
20
20
// retain multiline comment with @license
21
21
uglifyOpts . output . comments = ( node , comment ) =>
22
22
comment . type === 'comment2' && / @ l i c e n s e / i. test ( comment . value ) ;
23
23
24
- var plugins = [
24
+ let plugins = [
25
25
nodeResolve ( { jsnext : true } ) ,
26
26
progress ( ) ,
27
27
sourcemaps ( ) ,
@@ -31,15 +31,7 @@ var plugins = [
31
31
if ( MINIFY ) plugins . push ( uglify ( uglifyOpts ) ) ;
32
32
if ( MINIFY ) plugins . push ( visualizer ( { sourcemap : true } ) ) ;
33
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
- } ;
34
+ let extension = MINIFY ? '.min.js' : '.js' ;
43
35
44
36
// Suppress this error message... there are hundreds of them. Angular team says to ignore it.
45
37
// https://github.com/rollup/rollup/wiki/Troubleshooting#this-is-undefined
@@ -48,37 +40,58 @@ function onwarn(warning) {
48
40
console . error ( warning . message ) ;
49
41
}
50
42
51
- const ROUTER_CONFIG = Object . assign ( {
43
+ function isExternal ( id ) {
44
+ // All rxjs and @angular /* should be external
45
+ // except for @angular /router/src/router_config_loader
46
+ let externals = [ / ^ r x j s / , / ^ @ a n g u l a r \/ (? ! r o u t e r \/ s r c \/ r o u t e r _ c o n f i g _ l o a d e r ) / , ] ;
47
+ return externals . map ( regex => regex . exec ( id ) ) . reduce ( ( acc , val ) => acc || ! ! val , false ) ;
48
+ }
49
+
50
+ const CONFIG = {
52
51
moduleName : 'ui-router-ng2' ,
53
52
entry : 'lib/index.js' ,
54
53
dest : '_bundles/ui-router-ng2' + extension ,
55
- context : 'undefined' ,
54
+
55
+ sourceMap : true ,
56
+ format : 'umd' ,
57
+ exports : 'named' ,
58
+ plugins : plugins ,
59
+ banner : banner ,
60
+
56
61
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
- ] ,
62
+ external : isExternal ,
63
+
74
64
globals : {
75
- '@angular/core' : 'ng.core' ,
76
- '@angular/common' : 'ng.common' ,
65
+ 'rxjs/ReplaySubject' : 'Rx' ,
66
+
67
+ // Copied these from @angular /router rollup config
68
+ 'rxjs/BehaviorSubject' : 'Rx' ,
77
69
'rxjs/Observable' : 'Rx' ,
78
70
'rxjs/Subject' : 'Rx' ,
79
- 'rxjs/BehaviorSubject' : 'Rx' ,
80
- 'rxjs/ReplaySubject' : 'Rx' ,
71
+ 'rxjs/Subscription' : 'Rx' ,
72
+ 'rxjs/util/EmptyError' : 'Rx' ,
73
+
74
+ 'rxjs/observable/from' : 'Rx.Observable' ,
75
+ 'rxjs/observable/fromPromise' : 'Rx.Observable' ,
76
+ 'rxjs/observable/forkJoin' : 'Rx.Observable' ,
77
+ 'rxjs/observable/of' : 'Rx.Observable' ,
78
+
79
+ 'rxjs/operator/toPromise' : 'Rx.Observable.prototype' ,
80
+ 'rxjs/operator/map' : 'Rx.Observable.prototype' ,
81
+ 'rxjs/operator/mergeAll' : 'Rx.Observable.prototype' ,
82
+ 'rxjs/operator/concatAll' : 'Rx.Observable.prototype' ,
83
+ 'rxjs/operator/mergeMap' : 'Rx.Observable.prototype' ,
84
+ 'rxjs/operator/reduce' : 'Rx.Observable.prototype' ,
85
+ 'rxjs/operator/every' : 'Rx.Observable.prototype' ,
86
+ 'rxjs/operator/first' : 'Rx.Observable.prototype' ,
87
+ 'rxjs/operator/catch' : 'Rx.Observable.prototype' ,
88
+ 'rxjs/operator/last' : 'Rx.Observable.prototype' ,
89
+ 'rxjs/operator/filter' : 'Rx.Observable.prototype' ,
90
+ 'rxjs/operator/concatMap' : 'Rx.Observable.prototype' ,
91
+
92
+ '@angular/core' : 'ng.core' ,
93
+ '@angular/common' : 'ng.common' ,
81
94
}
82
- } , BASE_CONFIG ) ;
95
+ } ;
83
96
84
- export default ROUTER_CONFIG ;
97
+ export default CONFIG ;
0 commit comments