Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dead-code elimination of unused default parameters #1199

Open
bitjson opened this issue May 17, 2022 · 0 comments
Open

Dead-code elimination of unused default parameters #1199

bitjson opened this issue May 17, 2022 · 0 comments

Comments

@bitjson
Copy link

bitjson commented May 17, 2022

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));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant