Research
Security News
Threat Actor Exposes Playbook for Exploiting npm to Build Blockchain-Powered Botnets
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.
babel-plugin-minify-dead-code-elimination
Advanced tools
Inlines bindings when possible. Tries to evaluate expressions and prunes unreachable as a result.
The babel-plugin-minify-dead-code-elimination package is a Babel plugin that helps in removing dead code from your JavaScript files. This can significantly reduce the size of your code by eliminating code that is never executed, such as unreachable code, unused variables, and functions.
Remove Unreachable Code
This feature removes code that is never executed. In the example, the `if` block will be removed because the condition is always false.
const condition = false;
if (condition) {
console.log('This will never be logged');
}
Remove Unused Variables
This feature removes variables that are declared but never used. In the example, `unusedVar` will be removed because it is never used.
const unusedVar = 42;
const usedVar = 24;
console.log(usedVar);
Remove Unused Functions
This feature removes functions that are declared but never called. In the example, `unusedFunction` will be removed because it is never called.
function unusedFunction() {
return 'I am not used';
}
function usedFunction() {
return 'I am used';
}
console.log(usedFunction());
UglifyJS is a JavaScript parser, minifier, compressor, and beautifier toolkit. It can also remove dead code, but it is a more general-purpose tool compared to babel-plugin-minify-dead-code-elimination, which is specifically designed for dead code elimination.
Terser is a JavaScript parser and mangler/compressor toolkit for ES6+. It is a fork of UglifyJS and offers similar functionalities, including dead code elimination. Terser is often used in modern JavaScript projects for minification and dead code removal.
This is a Rollup plugin that integrates Terser for minification and dead code elimination. It is specifically designed to work with Rollup, a module bundler for JavaScript, making it a good choice for projects that use Rollup.
Inlines bindings when possible. Tries to evaluate expressions and prunes unreachable as a result.
In
function foo() {var x = 1;}
function bar() { var x = f(); }
function baz() {
var x = 1;
console.log(x);
function unused() {
return 5;
}
}
Out
function foo() {}
function bar() { f(); }
function baz() {
console.log(1);
}
npm install babel-plugin-minify-dead-code-elimination --save-dev
.babelrc
(Recommended).babelrc
// without options
{
"plugins": ["minify-dead-code-elimination"]
}
// with options
{
"plugins": ["minify-dead-code-elimination", { "optimizeRawSize": true }]
}
babel --plugins minify-dead-code-elimination script.js
require("@babel/core").transform("code", {
plugins: ["minify-dead-code-elimination"]
});
keepFnName
- prevent plugin from removing function name. Useful for code depending on fn.name
keepFnArgs
- prevent plugin from removing function args. Useful for code depending on fn.length
keepClassName
- prevent plugin from removing class name. Useful for code depending on cls.name
tdz
- Account for TDZ (Temporal Dead Zone)FAQs
Inlines bindings when possible. Tries to evaluate expressions and prunes unreachable as a result.
The npm package babel-plugin-minify-dead-code-elimination receives a total of 458,885 weekly downloads. As such, babel-plugin-minify-dead-code-elimination popularity was classified as popular.
We found that babel-plugin-minify-dead-code-elimination demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 5 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.
Security News
NVD’s backlog surpasses 20,000 CVEs as analysis slows and NIST announces new system updates to address ongoing delays.
Security News
Research
A malicious npm package disguised as a WhatsApp client is exploiting authentication flows with a remote kill switch to exfiltrate data and destroy files.