@@ -53,10 +53,29 @@ const ESM_DIALOG_POLYFILL = 'if(typeof window!==\'undefined\')' +
53
53
const DEFAULT_IMPORT_FIX = 'if(typeof firebase.default!==\'undefined\')' +
54
54
'{firebase=firebase.default;}' ;
55
55
56
+ // The Material Design Lite components needed by FirebaseUI.
57
+ const MDL_COMPONENTS = [
58
+ 'mdlComponentHandler' ,
59
+ 'button/button' ,
60
+ 'progress/progress' ,
61
+ 'spinner/spinner' ,
62
+ 'textfield/textfield'
63
+ ]
64
+
65
+ // The external dependencies needed by FirebaseUI as ES module imports.
66
+ const ESM_DEPS = [
67
+ 'import * as firebase from \'firebase/app\'' ,
68
+ 'import \'firebase/auth\'' ,
69
+ 'import dialogPolyfill from \'dialog-polyfill\'' ,
70
+ ] . concat ( MDL_COMPONENTS . map ( component => `import \'material-design-lite/src/${ component } \'` ) )
71
+
72
+ // The external dependencies needed by FirebaseUI as CommonJS modules.
73
+ const CJS_DEPS = [
74
+ 'node_modules/dialog-polyfill/dialog-polyfill.js'
75
+ ] . concat ( MDL_COMPONENTS . map ( component => `node_modules/material-design-lite/src/${ component } .js` ) ) ;
76
+
56
77
// Import esm modules.
57
- const ESM_IMPORT = 'import * as firebase from \'firebase/app\';' +
58
- 'import \'firebase/auth\';' +
59
- 'import dialogPolyfill from \'dialog-polyfill\';' ;
78
+ const ESM_IMPORT = ESM_DEPS . join ( ';' ) + ';' ;
60
79
61
80
// Export firebaseui.auth module.
62
81
const ESM_EXPORT = 'const auth = firebaseui.auth;' +
@@ -106,16 +125,6 @@ const COMPILER_DEFAULT_ARGS = {
106
125
language_out : 'ES5'
107
126
} ;
108
127
109
- // The external dependencies needed by FirebaseUI.
110
- const JS_DEPS = [
111
- 'node_modules/material-design-lite/src/mdlComponentHandler.js' ,
112
- 'node_modules/material-design-lite/src/button/button.js' ,
113
- 'node_modules/material-design-lite/src/progress/progress.js' ,
114
- 'node_modules/material-design-lite/src/spinner/spinner.js' ,
115
- 'node_modules/material-design-lite/src/textfield/textfield.js' ,
116
- 'node_modules/dialog-polyfill/dialog-polyfill.js'
117
- ] ;
118
-
119
128
// The typescript definitions file path.
120
129
const TYPES_FILE = './types/index.d.ts' ;
121
130
@@ -241,12 +250,13 @@ function buildFirebaseUiJs(locale) {
241
250
* @param {string } locale The desired FirebaseUI locale.
242
251
* @param {string } outBaseName The prefix of the output file name.
243
252
* @param {string } outputWrapper A wrapper with which to wrap the output JS.
253
+ * @param {string[] } dependencies The dependencies to concatenate.
244
254
* @return {* } A stream that ends when compilation finishes.
245
255
*/
246
- function concatWithDeps ( locale , outBaseName , outputWrapper ) {
256
+ function concatWithDeps ( locale , outBaseName , outputWrapper , dependencies = [ ] ) {
247
257
const localeForFileName = getLocaleForFileName ( locale ) ;
248
258
// Get a list of the FirebaseUI JS and its dependencies.
249
- const srcs = JS_DEPS . concat ( [ getTmpJsPath ( locale ) ] ) ;
259
+ const srcs = dependencies . concat ( [ getTmpJsPath ( locale ) ] ) ;
250
260
const outputPath = `${ DEST_DIR } /${ outBaseName } __${ localeForFileName } .js` ;
251
261
return compile ( srcs , outputPath , {
252
262
compilation_level : 'WHITESPACE_ONLY' ,
@@ -288,7 +298,7 @@ repeatTaskForAllLocales(
288
298
// the NPM module for all languages.
289
299
repeatTaskForAllLocales (
290
300
'build-npm-$' , [ 'build-firebaseui-js-$' ] ,
291
- ( locale ) => concatWithDeps ( locale , 'npm' , NPM_MODULE_WRAPPER ) ) ;
301
+ ( locale ) => concatWithDeps ( locale , 'npm' , NPM_MODULE_WRAPPER , CJS_DEPS ) ) ;
292
302
293
303
// Bundles the FirebaseUI JS with its dependencies as a ESM module. This builds
294
304
// the NPM module for all languages.
@@ -300,7 +310,7 @@ repeatTaskForAllLocales(
300
310
// Generates the gulp tasks build-js-de, build-js-fr, etc.
301
311
const buildJsTasks = repeatTaskForAllLocales (
302
312
'build-js-$' , [ 'build-firebaseui-js-$' ] ,
303
- ( locale ) => concatWithDeps ( locale , 'firebaseui' , OUTPUT_WRAPPER ) ) ;
313
+ ( locale ) => concatWithDeps ( locale , 'firebaseui' , OUTPUT_WRAPPER , CJS_DEPS ) ) ;
304
314
305
315
// Builds the final JS file for the default language.
306
316
gulp . task ( 'build-js' , gulp . series (
0 commit comments