From f4eb2bb5433d2a27e2d819bc7e82f0dd41cd04fd Mon Sep 17 00:00:00 2001 From: Josep Sayol Date: Fri, 16 Nov 2018 15:07:33 +0100 Subject: [PATCH 1/3] Generate smaller bundles (take 2) --- packages/firebase/rollup.config.js | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/packages/firebase/rollup.config.js b/packages/firebase/rollup.config.js index ae5aa2e1ead..08053178366 100644 --- a/packages/firebase/rollup.config.js +++ b/packages/firebase/rollup.config.js @@ -49,6 +49,20 @@ const plugins = [ const external = Object.keys(pkg.dependencies || {}); +const uglifyOptions = { + mangle: { + properties: { + keep_quoted: true, + regex: /_$|^_/ + } + }, + compress: { + passes: 3, + unsafe: true, + warnings: false, + } +}; + /** * Global UMD Build */ @@ -81,7 +95,7 @@ const appBuilds = [ format: 'umd', name: GLOBAL_NAME }, - plugins: [...plugins, uglify()] + plugins: [...plugins, uglify(uglifyOptions)] } ]; @@ -138,7 +152,7 @@ const componentBuilds = components ); }` }, - plugins: [...plugins, uglify()], + plugins: [...plugins, uglify(component !== 'auth' ? uglifyOptions : {})], external: ['@firebase/app'] } ]; @@ -168,7 +182,7 @@ const completeBuilds = [ format: 'umd', name: GLOBAL_NAME }, - plugins: [...plugins, uglify()] + plugins: [...plugins, uglify(uglifyOptions)] }, /** * App Node.js Builds From be11c73ca36af39b83c9bcc5a95c8acc0e7056f7 Mon Sep 17 00:00:00 2001 From: Josep Sayol Date: Fri, 16 Nov 2018 23:41:07 +0100 Subject: [PATCH 2/3] Address review comment --- packages/firebase/rollup.config.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/packages/firebase/rollup.config.js b/packages/firebase/rollup.config.js index 08053178366..ab4a494778c 100644 --- a/packages/firebase/rollup.config.js +++ b/packages/firebase/rollup.config.js @@ -57,9 +57,7 @@ const uglifyOptions = { } }, compress: { - passes: 3, - unsafe: true, - warnings: false, + passes: 3 } }; @@ -152,7 +150,10 @@ const componentBuilds = components ); }` }, - plugins: [...plugins, uglify(component !== 'auth' ? uglifyOptions : {})], + plugins: [ + ...plugins, + uglify(component !== 'auth' ? uglifyOptions : {}) + ], external: ['@firebase/app'] } ]; From 847868fe6861288747fe5b60f16b4f4fd2903976 Mon Sep 17 00:00:00 2001 From: Josep Sayol Date: Wed, 21 Nov 2018 00:02:49 +0100 Subject: [PATCH 3/3] Prevent mangling properties with double underscore --- packages/firebase/rollup.config.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/firebase/rollup.config.js b/packages/firebase/rollup.config.js index ab4a494778c..c8f44ddf87e 100644 --- a/packages/firebase/rollup.config.js +++ b/packages/firebase/rollup.config.js @@ -53,7 +53,7 @@ const uglifyOptions = { mangle: { properties: { keep_quoted: true, - regex: /_$|^_/ + regex: /(^_[^_])|([^_]_$)/ } }, compress: {