@@ -52,7 +52,7 @@ function cleanDist(dir) {
52
52
53
53
function compileTypescriptToES2015 ( ) {
54
54
const stream = tsProject . src ( )
55
- . pipe ( sourcemaps . init ( { loadMaps : true } ) )
55
+ . pipe ( sourcemaps . init ( { loadMaps : true } ) )
56
56
. pipe ( tsProject ( ) ) ;
57
57
return merge ( [
58
58
stream . dts
@@ -65,7 +65,7 @@ function compileTypescriptToES2015() {
65
65
66
66
function compileES2015ToCJS ( ) {
67
67
return gulp . src ( 'dist/es2015/**/*.js' )
68
- . pipe ( sourcemaps . init ( { loadMaps : true } ) )
68
+ . pipe ( sourcemaps . init ( { loadMaps : true } ) )
69
69
. pipe ( babel ( config . babel ) )
70
70
. pipe ( sourcemaps . write ( '.' ) )
71
71
. pipe ( gulp . dest ( `${ config . paths . outDir } /cjs` ) )
@@ -115,30 +115,46 @@ function compileIndvES2015ModulesToBrowser() {
115
115
return pathObj . name === 'firebase-app' ;
116
116
} ;
117
117
118
- // Webpack config for compiling indv modules
118
+ const babelLoader = {
119
+ loader : 'babel-loader' ,
120
+ options : config . babel
121
+ } ;
122
+
123
+ const tsLoader = {
124
+ loader : 'ts-loader' ,
125
+ options : {
126
+ compilerOptions : {
127
+ declaration : false
128
+ }
129
+ }
130
+ } ;
131
+
119
132
const webpackConfig = {
133
+ devtool : 'source-map' ,
120
134
entry : {
121
- 'firebase-app' : './dist/es2015/ app.js ' ,
122
- 'firebase-storage' : './dist/es2015/ storage.js ' ,
123
- 'firebase-messaging' : './dist/es2015/ messaging.js ' ,
135
+ 'firebase-app' : './src/ app.ts ' ,
136
+ 'firebase-storage' : './src/ storage.ts ' ,
137
+ 'firebase-messaging' : './src/ messaging.ts ' ,
124
138
} ,
125
139
output : {
126
- filename : '[name].js' ,
140
+ path : path . resolve ( __dirname , './dist/browser' ) ,
141
+ filename : '[name].js'
127
142
} ,
128
143
module : {
129
- rules : [
130
- {
131
- test : / \. j s $ / ,
132
- exclude : / ( n o d e _ m o d u l e s | b o w e r _ c o m p o n e n t s ) / ,
133
- use : {
134
- loader : 'babel-loader' ,
135
- options : {
136
- presets : config . babel . presets ,
137
- plugins : config . babel . plugins
138
- }
139
- }
140
- }
141
- ]
144
+ rules : [ {
145
+ test : / \. t s ( x ? ) $ / ,
146
+ exclude : / n o d e _ m o d u l e s / ,
147
+ use : [
148
+ babelLoader ,
149
+ tsLoader
150
+ ]
151
+ } , {
152
+ test : / \. j s $ / ,
153
+ exclude : / n o d e _ m o d u l e s / ,
154
+ use : [
155
+ babelLoader
156
+ ]
157
+ } ]
142
158
} ,
143
159
plugins : [
144
160
new webpack . optimize . CommonsChunkPlugin ( {
@@ -147,7 +163,7 @@ function compileIndvES2015ModulesToBrowser() {
147
163
new WrapperPlugin ( {
148
164
header : fileName => {
149
165
return isFirebaseApp ( fileName ) ? `var firebase = (function() {
150
- var window = typeof window === 'undefined' ? self : window;
166
+ var window = typeof window === 'undefined' ? self : window;
151
167
return ` : `try {
152
168
` ;
153
169
} ,
@@ -162,20 +178,17 @@ function compileIndvES2015ModulesToBrowser() {
162
178
}`
163
179
}
164
180
} ) ,
165
- new webpack . optimize . UglifyJsPlugin ( )
166
- ]
167
- } ;
168
- return gulp . src ( './dist/es2015/firebase.js' )
181
+ new webpack . optimize . UglifyJsPlugin ( {
182
+ sourceMap : true
183
+ } )
184
+ ] ,
185
+ resolve : {
186
+ extensions : [ '.ts' , '.tsx' , '.js' ]
187
+ } ,
188
+ }
189
+
190
+ return gulp . src ( 'src/**/*.ts' )
169
191
. pipe ( webpackStream ( webpackConfig , webpack ) )
170
- . pipe ( sourcemaps . init ( { loadMaps : true } ) )
171
- . pipe ( through . obj ( function ( file , enc , cb ) {
172
- // Dont pipe through any source map files as it will be handled
173
- // by gulp-sourcemaps
174
- var isSourceMap = / \. m a p $ / . test ( file . path ) ;
175
- if ( ! isSourceMap ) this . push ( file ) ;
176
- cb ( ) ;
177
- } ) )
178
- . pipe ( sourcemaps . write ( '.' ) )
179
192
. pipe ( gulp . dest ( `${ config . paths . outDir } /browser` ) ) ;
180
193
}
181
194
@@ -188,7 +201,7 @@ function compileSDKES2015ToBrowser() {
188
201
} )
189
202
]
190
203
} , webpack ) )
191
- . pipe ( sourcemaps . init ( { loadMaps : true } ) )
204
+ . pipe ( sourcemaps . init ( { loadMaps : true } ) )
192
205
. pipe ( through . obj ( function ( file , enc , cb ) {
193
206
// Dont pipe through any source map files as it will be handled
194
207
// by gulp-sourcemaps
@@ -202,7 +215,9 @@ function compileSDKES2015ToBrowser() {
202
215
203
216
function buildBrowserFirebaseJs ( ) {
204
217
return gulp . src ( './dist/browser/*.js' )
218
+ . pipe ( sourcemaps . init ( { loadMaps : true } ) )
205
219
. pipe ( concat ( 'firebase.js' ) )
220
+ . pipe ( sourcemaps . write ( '.' ) )
206
221
. pipe ( gulp . dest ( `${ config . paths . outDir } /browser` ) ) ;
207
222
}
208
223
@@ -223,7 +238,7 @@ function buildAltEnvFirebaseJs() {
223
238
]
224
239
} ) ;
225
240
return gulp . src ( './dist/es2015/firebase.js' )
226
- . pipe ( sourcemaps . init ( { loadMaps : true } ) )
241
+ . pipe ( sourcemaps . init ( { loadMaps : true } ) )
227
242
. pipe ( babel ( babelConfig ) )
228
243
. pipe ( rename ( {
229
244
suffix : `-${ env } `
0 commit comments