babel-plugin-minify-dead-code-elimination should remove unused arguments
See original GitHub issueOriginal issue: https://github.com/babel/babel/issues/4531
Input Code
Here’s a reproduction repo
const foo = (arg1, arg2) => arg1
.babelrc (or what it might look like)
{
"plugins": ["minify-dead-code-elimination"]
}
Expected Behavior
I would expect the output to be:
const foo = (arg1) => arg1
Current Behavior
Instead, the plugin doesn’t do anything with unused arguments
const foo = (arg1, arg2) => arg1
Possible Solution
I’m not certain whether this is totally the responsibility of babel-plugin-minify-dead-code-elimination
, but I can’t think of any other plugin that should do this.
Context
I’m writing a program slicing tool that’s using babel-plugin-minify-dead-code-elimination
directly to remove dead code after I’ve manipulated the AST to remove sliced nodes.
Your Environment
software | version |
---|---|
Babel | 6.14.0 |
node | 6.5.0 |
npm | 3.10.7 |
Operating System | Mac OSX |
Issue Analytics
- State:
- Created 7 years ago
- Comments:8 (6 by maintainers)
Top Results From Across the Web
babel-plugin-minify-dead-code-elimination-while-loop-fixed
Inlines bindings when possible. Tries to evaluate expressions and prunes unreachable as a result.
Read more >Optimization
Dead code elimination in minimizers will benefit from this and can remove unused exports. webpack.config.js module.exports = { //... optimization: ...
Read more >Rollup minify
GitHub - Comandeer/rollup-plugin-babel-minify: Simple rollup plugin for minifying ... A minifier can eliminate unused code, and this is how Webpack achieves ...
Read more >Terser
Note that currently not *all* comments can be kept when compression is on, because of dead code removal or cascading statements into sequences....
Read more >Advanced Compilation | Closure Compiler
You may encounter unwanted code removal if you only compile part of your code with Closure Compiler. For example, you might have a...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I just figured this one out and did that as we speak. That was a very quick response. Thank you
You can use the
keepFnArgs
option to disable this behavior: https://github.com/babel/minify/blob/8b7ed4adfc963f3c84d4a74c18e6a42aadb1396b/packages/babel-plugin-minify-dead-code-elimination/README.md#options