Skip to content

Commit 63fc7df

Browse files
wip(build): improve build size (embedded polyfills) by excluding cases that make no sense
1 parent 51a423b commit 63fc7df

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

build/webpack.config.js

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,10 @@ const configure = ({name, vueTarget, libraryTargetModule}) => (env = {}, { mode
8383

8484
const genSourcemap = false;
8585

86-
console.log('config', { targetsBrowsers, noPresetEnv, noCompress, noSourceMap, genSourcemap, libraryTargetModule, vueTarget });
86+
// excludes cases that make no sense
87+
const actualTargetsBrowsers = targetsBrowsers + ( libraryTargetModule ? ' and supports es6-module' : '' ) + ( vueTarget == 3 ? ' and supports proxy' : '' );
88+
89+
console.log('config', { actualTargetsBrowsers, noPresetEnv, noCompress, noSourceMap, genSourcemap, libraryTargetModule, vueTarget });
8790

8891
return {
8992
name,
@@ -113,10 +116,10 @@ const configure = ({name, vueTarget, libraryTargetModule}) => (env = {}, { mode
113116
environment: {
114117
// doc: https://webpack.js.org/configuration/output/#outputenvironment
115118
...!noPresetEnv ? {
116-
arrowFunction: caniuse.isSupported('arrow-functions', targetsBrowsers),
117-
const: caniuse.isSupported('const', targetsBrowsers),
118-
destructuring: caniuse.isSupported('es6', targetsBrowsers), // see https://github.com/Fyrd/caniuse/issues/5676
119-
forOf: caniuse.isSupported('es6', targetsBrowsers),
119+
arrowFunction: caniuse.isSupported('arrow-functions', actualTargetsBrowsers),
120+
const: caniuse.isSupported('const', actualTargetsBrowsers),
121+
destructuring: caniuse.isSupported('es6', actualTargetsBrowsers), // see https://github.com/Fyrd/caniuse/issues/5676
122+
forOf: caniuse.isSupported('es6', actualTargetsBrowsers),
120123
} : {},
121124
},
122125
},
@@ -186,8 +189,8 @@ const configure = ({name, vueTarget, libraryTargetModule}) => (env = {}, { mode
186189
passes: 2,
187190
drop_console: true,
188191
...!noPresetEnv ? {
189-
arrows: caniuse.isSupported('arrow-functions', targetsBrowsers),
190-
ecma: caniuse.isSupported('es6', targetsBrowsers) ? '2015' : '5', // note ECMAScript 2015 is the sixth edition of the ECMAScript Language Specification standard
192+
arrows: caniuse.isSupported('arrow-functions', actualTargetsBrowsers),
193+
ecma: caniuse.isSupported('es6', actualTargetsBrowsers) ? '2015' : '5', // note ECMAScript 2015 is the sixth edition of the ECMAScript Language Specification standard
191194
} : {},
192195

193196
// beware, unsafe: true is not suitable for this project !
@@ -196,7 +199,7 @@ const configure = ({name, vueTarget, libraryTargetModule}) => (env = {}, { mode
196199
// unsafe_Function: true,
197200
// unsafe_math: true,
198201
// unsafe_symbols: true,
199-
// unsafe_methods: caniuse.isSupported('es6', targetsBrowsers),
202+
// unsafe_methods: caniuse.isSupported('es6', actualTargetsBrowsers),
200203
// unsafe_proto: true,
201204
// unsafe_regexp: true,
202205
// unsafe_undefined: true,
@@ -352,7 +355,7 @@ ${ pkg.name } v${ pkg.version } for vue${ vueTarget }
352355
compact: !noCompress,
353356
sourceMaps: !noSourceMap,
354357
sourceType: 'unambiguous', // doc: https://babeljs.io/docs/en/options#sourcetype
355-
targets: targetsBrowsers,
358+
targets: actualTargetsBrowsers,
356359
presets: [
357360

358361
...!noPresetEnv ? [

0 commit comments

Comments
 (0)