@@ -52,7 +52,7 @@ function cleanDist(dir) {
5252
5353function compileTypescriptToES2015 ( ) {
5454 const stream = tsProject . src ( )
55- . pipe ( sourcemaps . init ( { loadMaps : true } ) )
55+ . pipe ( sourcemaps . init ( { loadMaps : true } ) )
5656 . pipe ( tsProject ( ) ) ;
5757 return merge ( [
5858 stream . dts
@@ -65,7 +65,7 @@ function compileTypescriptToES2015() {
6565
6666function compileES2015ToCJS ( ) {
6767 return gulp . src ( 'dist/es2015/**/*.js' )
68- . pipe ( sourcemaps . init ( { loadMaps : true } ) )
68+ . pipe ( sourcemaps . init ( { loadMaps : true } ) )
6969 . pipe ( babel ( config . babel ) )
7070 . pipe ( sourcemaps . write ( '.' ) )
7171 . pipe ( gulp . dest ( `${ config . paths . outDir } /cjs` ) )
@@ -115,30 +115,46 @@ function compileIndvES2015ModulesToBrowser() {
115115 return pathObj . name === 'firebase-app' ;
116116 } ;
117117
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+
119132 const webpackConfig = {
133+ devtool : 'source-map' ,
120134 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 ' ,
124138 } ,
125139 output : {
126- filename : '[name].js' ,
140+ path : path . resolve ( __dirname , './dist/browser' ) ,
141+ filename : '[name].js'
127142 } ,
128143 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+ } ]
142158 } ,
143159 plugins : [
144160 new webpack . optimize . CommonsChunkPlugin ( {
@@ -147,7 +163,7 @@ function compileIndvES2015ModulesToBrowser() {
147163 new WrapperPlugin ( {
148164 header : fileName => {
149165 return isFirebaseApp ( fileName ) ? `var firebase = (function() {
150- var window = typeof window === 'undefined' ? self : window;
166+ var window = typeof window === 'undefined' ? self : window;
151167 return ` : `try {
152168 ` ;
153169 } ,
@@ -162,20 +178,17 @@ function compileIndvES2015ModulesToBrowser() {
162178 }`
163179 }
164180 } ) ,
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' )
169191 . 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 ( '.' ) )
179192 . pipe ( gulp . dest ( `${ config . paths . outDir } /browser` ) ) ;
180193}
181194
@@ -188,7 +201,7 @@ function compileSDKES2015ToBrowser() {
188201 } )
189202 ]
190203 } , webpack ) )
191- . pipe ( sourcemaps . init ( { loadMaps : true } ) )
204+ . pipe ( sourcemaps . init ( { loadMaps : true } ) )
192205 . pipe ( through . obj ( function ( file , enc , cb ) {
193206 // Dont pipe through any source map files as it will be handled
194207 // by gulp-sourcemaps
@@ -202,7 +215,9 @@ function compileSDKES2015ToBrowser() {
202215
203216function buildBrowserFirebaseJs ( ) {
204217 return gulp . src ( './dist/browser/*.js' )
218+ . pipe ( sourcemaps . init ( { loadMaps : true } ) )
205219 . pipe ( concat ( 'firebase.js' ) )
220+ . pipe ( sourcemaps . write ( '.' ) )
206221 . pipe ( gulp . dest ( `${ config . paths . outDir } /browser` ) ) ;
207222}
208223
@@ -223,7 +238,7 @@ function buildAltEnvFirebaseJs() {
223238 ]
224239 } ) ;
225240 return gulp . src ( './dist/es2015/firebase.js' )
226- . pipe ( sourcemaps . init ( { loadMaps : true } ) )
241+ . pipe ( sourcemaps . init ( { loadMaps : true } ) )
227242 . pipe ( babel ( babelConfig ) )
228243 . pipe ( rename ( {
229244 suffix : `-${ env } `
0 commit comments