terser/terser

Dead-code elimination of unused default parameters

bitjson opened this issue · 0 comments

Feature request

Default parameters that aren't used by the bundle can be removed.

Version (complete output of terser -V or specific git commit)

5.13.1

Complete CLI command or minify() options used

terser file.js --module --compress (Also tested using default configuration at https://try.terser.org/)

terser input

file.js:

const internalAdd = (a, b) => (a === '0' ? b : a + b); // should not appear in bundle
const addAndLog = (a, b, impl = internalAdd) => console.log(impl(a, b));
const myAdd = (a, b) => a + b;
addAndLog(1, 2, myAdd); // => 3

terser output or error

const internalAdd=(a,b)=>"0"===a?b:a+b;((a,b,impl=internalAdd)=>{console.log(impl(a,b))})(1,2,((a,b)=>a+b));

Expected result

Expected result should be equivalent to the result for this input:

const addAndLog = (a, b, impl) => console.log(impl(a, b));
const myAdd = (a, b) => a + b;
addAndLog(1, 2, myAdd); // => 3

Result:

var a,b,impl;a=1,b=2,impl=(a,b)=>a+b,console.log(impl(a,b));