Minify: Minify options

Created on 20 Jul 2016  路  3Comments  路  Source: babel/minify

Since it is a preset, there won't be any options passed to the minifier.

for example,

  • mangle topLevel names
  • mangle eval accessible bindings - don't deopt because of the presense of eval
  • apply unsafe optimizations like - !== to !=, >= to <
  • drop debugger & console statements or just one of them
  • preserve fn args and fn name for code depending on fn.length & fn.name

etc...

How to support these as options to be passed to the minifier - when used as a CLI or a Preset?

enhancement

Most helpful comment

Yay! It's merged now - https://github.com/babel/babel/pull/3331. We could start discussion about the list of options.

mangle : bool | {
  keepFnames: bool, // overrides keepFnames in root
  eval: bool,
  blacklist: [string]
},
deadcode: bool | {
  keepFnames: bool, // overrides keepFnames in root
  keepFargs: bool,
},
keepFnames: bool, // passed to DCE and Mangler
unsafe: bool | {
  flipComparisons,
  typeConstructors,
  simplifyComparisons,
  guardedExpr,
},
evaluate: bool, // constant folding,
simplify: bool, // simplify, undef to void, 
booleans: bool,
properties: bool,

All 3 comments

we could land https://github.com/babel/babel/pull/3331 before that (options for presets)?

Yay! It's merged now - https://github.com/babel/babel/pull/3331. We could start discussion about the list of options.

mangle : bool | {
  keepFnames: bool, // overrides keepFnames in root
  eval: bool,
  blacklist: [string]
},
deadcode: bool | {
  keepFnames: bool, // overrides keepFnames in root
  keepFargs: bool,
},
keepFnames: bool, // passed to DCE and Mangler
unsafe: bool | {
  flipComparisons,
  typeConstructors,
  simplifyComparisons,
  guardedExpr,
},
evaluate: bool, // constant folding,
simplify: bool, // simplify, undef to void, 
booleans: bool,
properties: bool,

I would much appreciate a keepClassNames option

Was this page helpful?
0 / 5 - 0 ratings