coderaiser/minify

Minify removes top-level js functions because it's "unused"

clrke opened this issue · 4 comments

clrke commented

I have a js file that I want to minify:

function pluralize(noun) {
  return noun + "s";
}

Problem is, this function gets ignored by minify because it is "not being used" locally but I WILL be using this in another file.

Can we only remove unused variables inside these top-level functions?

Yes, create .minify.json file with:

{
    "js": {
        "removeUnusedVariables": false
    }
}

Is it works for you?

clrke commented

@coderaiser Can we reopen? I want to keep removeUnusedVariables but only for those inside top-level functions.

This is not how @putout/plugin-remove-unused-variables works.

Why do you need to keep variables only inside top level functions? Could you please share code examples?