1
1
const { rollup } = require ( 'rollup' ) ;
2
2
const { spawn } = require ( 'child_process' ) ;
3
3
const { Observable } = require ( 'rxjs' ) ;
4
- const { copy, readFileSync, writeFile } = require ( 'fs-extra' ) ;
4
+ const { copy, readFileSync, writeFile, statSync } = require ( 'fs-extra' ) ;
5
5
const { prettySize } = require ( 'pretty-size' ) ;
6
6
const gzipSize = require ( 'gzip-size' ) ;
7
7
const resolve = require ( 'rollup-plugin-node-resolve' ) ;
@@ -29,6 +29,18 @@ const GLOBALS = {
29
29
'rxjs/operator/take' : 'Rx.Observable.prototype' ,
30
30
'rxjs/operator/toArray' : 'Rx.Observable.prototype' ,
31
31
'rxjs/operator/toPromise' : 'Rx.Observable.prototype' ,
32
+ 'rxjs/add/operator/map' : 'Rx.Observable.prototype' ,
33
+ 'rxjs/add/operator/scan' : 'Rx.Observable.prototype' ,
34
+ 'rxjs/add/operator/skip' : 'Rx.Observable.prototype' ,
35
+ 'rxjs/add/operator/do' : 'Rx.Observable.prototype' ,
36
+ 'rxjs/add/operator/filter' : 'Rx.Observable.prototype' ,
37
+ 'rxjs/add/operator/skipUntil' : 'Rx.Observable.prototype' ,
38
+ 'rxjs/add/operator/skipWhile' : 'Rx.Observable.prototype' ,
39
+ 'rxjs/add/operator/withLatestFrom' : 'Rx.Observable.prototype' ,
40
+ 'rxjs/add/observable/merge' : 'Rx.Observable' ,
41
+ 'rxjs/add/operator/delay' : 'Rx.Observable' ,
42
+ 'rxjs/add/operator/debounce' : 'Rx.Observable' ,
43
+ 'rxjs/observable/fromEvent' : 'Rx.Observable' ,
32
44
'rxjs/operator' : 'Rx.Observable.prototype' ,
33
45
'@angular/core' : 'ng.core' ,
34
46
'@angular/compiler' : 'ng.compiler' ,
@@ -41,6 +53,7 @@ const GLOBALS = {
41
53
'angularfire2' : 'angularfire2' ,
42
54
'angularfire2/auth' : 'angularfire2.auth' ,
43
55
'angularfire2/database' : 'angularfire2.database' ,
56
+ 'angularfire2/database-deprecated' : 'angularfire2.database_deprecated' ,
44
57
'angularfire2/firestore' : 'angularfire2.firestore'
45
58
} ;
46
59
@@ -54,6 +67,38 @@ const VERSIONS = {
54
67
FIRESTORE_VERSION : pkg . dependencies [ 'firestore' ]
55
68
} ;
56
69
70
+ const MODULE_NAMES = {
71
+ core : 'angularfire2' ,
72
+ auth : 'angularfire2.auth' ,
73
+ database : 'angularfire2.database' ,
74
+ "database-deprecated" : 'angularfire2.database_deprecated' ,
75
+ firestore : 'angularfire2.firestore'
76
+ } ;
77
+
78
+ const ENTRIES = {
79
+ core : `${ process . cwd ( ) } /dist/packages-dist/index.js` ,
80
+ auth : `${ process . cwd ( ) } /dist/packages-dist/auth/index.js` ,
81
+ database : `${ process . cwd ( ) } /dist/packages-dist/database/index.js` ,
82
+ "database-deprecated" : `${ process . cwd ( ) } /dist/packages-dist/database-deprecated/index.js` ,
83
+ firestore : `${ process . cwd ( ) } /dist/packages-dist/firestore/index.js`
84
+ } ;
85
+
86
+ const SRC_PKG_PATHS = {
87
+ core : `${ process . cwd ( ) } /src/core/package.json` ,
88
+ auth : `${ process . cwd ( ) } /src/auth/package.json` ,
89
+ database : `${ process . cwd ( ) } /src/database/package.json` ,
90
+ "database-deprecated" : `${ process . cwd ( ) } /src/database-deprecated/package.json` ,
91
+ firestore : `${ process . cwd ( ) } /src/firestore/package.json`
92
+ } ;
93
+
94
+ const DEST_PKG_PATHS = {
95
+ core : `${ process . cwd ( ) } /dist/packages-dist/package.json` ,
96
+ auth : `${ process . cwd ( ) } /dist/packages-dist/auth/package.json` ,
97
+ database : `${ process . cwd ( ) } /dist/packages-dist/database/package.json` ,
98
+ "database-deprecated" : `${ process . cwd ( ) } /dist/packages-dist/database-deprecated/package.json` ,
99
+ firestore : `${ process . cwd ( ) } /dist/packages-dist/firestore/package.json`
100
+ } ;
101
+
57
102
// Constants for running typescript commands
58
103
const TSC = 'node_modules/.bin/tsc' ;
59
104
const NGC = 'node_modules/.bin/ngc' ;
@@ -70,7 +115,7 @@ function spawnObservable(command, args) {
70
115
const cmd = spawn ( command , args ) ;
71
116
observer . next ( '' ) ; // hack to kick things off, not every command will have a stdout
72
117
cmd . stdout . on ( 'data' , ( data ) => { observer . next ( data . toString ( 'utf8' ) ) ; } ) ;
73
- cmd . stderr . on ( 'data' , ( data ) => { observer . error ( data . toString ( 'utf8' ) ) ; } ) ;
118
+ cmd . stderr . on ( 'data' , ( data ) => { console . log ( data ) ; observer . error ( data . toString ( 'utf8' ) ) ; } ) ;
74
119
cmd . on ( 'close' , ( data ) => { observer . complete ( ) ; } ) ;
75
120
} ) ;
76
121
}
@@ -95,18 +140,6 @@ function generateBundle(entry, { dest, globals, moduleName }) {
95
140
*/
96
141
function createUmd ( name , globals ) {
97
142
// core module is angularfire2 the rest are angularfire2.feature
98
- const MODULE_NAMES = {
99
- core : 'angularfire2' ,
100
- auth : 'angularfire2.auth' ,
101
- database : 'angularfire2.database' ,
102
- firestore : 'angularfire2.firestore'
103
- } ;
104
- const ENTRIES = {
105
- core : `${ process . cwd ( ) } /dist/packages-dist/index.js` ,
106
- auth : `${ process . cwd ( ) } /dist/packages-dist/auth/index.js` ,
107
- database : `${ process . cwd ( ) } /dist/packages-dist/database/index.js` ,
108
- firestore : `${ process . cwd ( ) } /dist/packages-dist/firestore/index.js` ,
109
- } ;
110
143
const moduleName = MODULE_NAMES [ name ] ;
111
144
const entry = ENTRIES [ name ] ;
112
145
return generateBundle ( entry , {
@@ -131,27 +164,15 @@ function createTestUmd(globals) {
131
164
* @param {string } moduleName
132
165
*/
133
166
function getSrcPackageFile ( moduleName ) {
134
- const PATHS = {
135
- core : `${ process . cwd ( ) } /src/core/package.json` ,
136
- auth : `${ process . cwd ( ) } /src/auth/package.json` ,
137
- database : `${ process . cwd ( ) } /src/database/package.json` ,
138
- firestore : `${ process . cwd ( ) } /src/firestore/package.json`
139
- } ;
140
- return PATHS [ moduleName ] ;
167
+ return SRC_PKG_PATHS [ moduleName ] ;
141
168
}
142
169
143
170
/**
144
171
* Get the file path of the dist package.json for a module
145
172
* @param {string } moduleName
146
173
*/
147
174
function getDestPackageFile ( moduleName ) {
148
- const PATHS = {
149
- core : `${ process . cwd ( ) } /dist/packages-dist/package.json` ,
150
- auth : `${ process . cwd ( ) } /dist/packages-dist/auth/package.json` ,
151
- database : `${ process . cwd ( ) } /dist/packages-dist/database/package.json` ,
152
- firestore : `${ process . cwd ( ) } /dist/packages-dist/firestore/package.json`
153
- } ;
154
- return PATHS [ moduleName ] ;
175
+ return DEST_PKG_PATHS [ moduleName ] ;
155
176
}
156
177
157
178
/**
@@ -200,10 +221,9 @@ function copyReadme() {
200
221
function measure ( module ) {
201
222
const path = `${ process . cwd ( ) } /dist/packages-dist/bundles/${ module } .umd.js` ;
202
223
const file = readFileSync ( path ) ;
203
- const bytes = gzipSize . sync ( file ) ;
204
- const gzipped = prettySize ( bytes , true ) ;
205
- const regular = prettySize ( bytes ) ;
206
- return { regular, gzipped } ;
224
+ const gzip = prettySize ( gzipSize . sync ( file ) , true ) ;
225
+ const size = prettySize ( statSync ( path ) . size , true ) ;
226
+ return { size, gzip } ;
207
227
}
208
228
209
229
/**
@@ -251,12 +271,12 @@ function buildModules(globals) {
251
271
const core$ = buildModule ( 'core' , globals ) ;
252
272
const auth$ = buildModule ( 'auth' , globals ) ;
253
273
const db$ = buildModule ( 'database' , globals ) ;
254
- const afs $ = buildModule ( 'firestore' , globals ) ;
274
+ const firestore $ = buildModule ( 'firestore' , globals ) ;
255
275
return Observable
256
276
. forkJoin ( core$ , Observable . from ( copyRootTest ( ) ) )
257
277
. switchMapTo ( auth$ )
258
278
. switchMapTo ( db$ )
259
- . switchMapTo ( afs $) ;
279
+ . switchMapTo ( firestore $) ;
260
280
}
261
281
262
282
function buildLibrary ( globals ) {
@@ -267,15 +287,15 @@ function buildLibrary(globals) {
267
287
. switchMap ( ( ) => Observable . from ( copyNpmIgnore ( ) ) )
268
288
. switchMap ( ( ) => Observable . from ( copyReadme ( ) ) )
269
289
. do ( ( ) => {
270
- const core = measure ( 'core' ) ;
271
- const auth = measure ( 'auth' ) ;
272
- const database = measure ( 'database' ) ;
273
- const firestore = measure ( 'firestore' ) ;
290
+ const coreStats = measure ( 'core' ) ;
291
+ const authStats = measure ( 'auth' ) ;
292
+ const dbStats = measure ( 'database' ) ;
293
+ const fsStats = measure ( 'firestore' ) ;
274
294
console . log ( `
275
- core.umd.js - ${ core . regular } , ${ core . gzipped }
276
- auth.umd.js - ${ auth . regular } , ${ auth . gzipped } }
277
- database.umd.js - ${ database . regular } , ${ database . gzipped } }
278
- firestore.umd.js - ${ firestore . regular } , ${ firestore . gzipped } }
295
+ core.umd.js - ${ coreStats . size } , ${ coreStats . gzip }
296
+ auth.umd.js - ${ authStats . size } , ${ authStats . gzip }
297
+ database.umd.js - ${ dbStats . size } , ${ dbStats . gzip }
298
+ firestore.umd.js - ${ fsStats . size } , ${ fsStats . gzip }
279
299
` ) ;
280
300
verifyVersions ( ) ;
281
301
} ) ;
0 commit comments