question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

babel-plugin-minify-dead-code-elimination should remove unused arguments

See original GitHub issue

Original 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:closed
  • Created 7 years ago
  • Comments:8 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
rajakollurucommented, Aug 20, 2017

I just figured this one out and did that as we speak. That was a very quick response. Thank you

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found