From 98af16208c6b2c939c7d424789b9a5df8687135b Mon Sep 17 00:00:00 2001 From: Nicolas Garnier Date: Tue, 15 May 2018 15:14:50 +0200 Subject: [PATCH] Using default attribute of Firebase require statement if available fixes #392 --- gulpfile.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/gulpfile.js b/gulpfile.js index ad4f33cd..b4de8721 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -42,13 +42,18 @@ const OUTPUT_WRAPPER = OPTIMIZATION_LEVEL === 'WHITESPACE_ONLY' ? const DIALOG_POLYFILL = 'if(typeof window!==\'undefined\')' + '{window.dialogPolyfill=require(\'dialog-polyfill\');}'; -// Adds the firebase module requirement and exports firebaseui. +// Using default import if available. +const DEFAULT_IMPORT_FIX = 'if(firebase.default!==\'undefined\')' + + '{firebase=firebase.default;}'; + +// Adds the module requirement and exports firebaseui. const NPM_MODULE_WRAPPER = OPTIMIZATION_LEVEL === 'WHITESPACE_ONLY' ? 'var firebase=require(\'firebase/app\');require(\'firebase/auth\');' + - '%output%' + DIALOG_POLYFILL + 'module.exports=firebaseui;' : + DEFAULT_IMPORT_FIX + '%output%' + DIALOG_POLYFILL + + 'module.exports=firebaseui;' : '(function() { var firebase=require(\'firebase/app\');' + - 'require(\'firebase/auth\');%output% ' + DIALOG_POLYFILL + '})();' + - 'module.exports=firebaseui;'; + 'require(\'firebase/auth\');' + DEFAULT_IMPORT_FIX + '%output% ' + + DIALOG_POLYFILL + '})();' + 'module.exports=firebaseui;'; // The path to Closure Compiler. const COMPILER_PATH = 'node_modules/google-closure-compiler/compiler.jar';