Registry / devops / babel-plugin-transform-dead-code-elimination

babel-plugin-transform-dead-code-elimination

JSON →
library2.2.3jsnpmunverified

A Babel 6 plugin that eliminates dead (unreachable) code, including unused variables, unreachable statements, and dead logical operators. It is a fork of babel-plugin-dead-code-elimination with additional fixes and features. Current stable version is v2.2.3, with releases in 2016 (last release 2.2.3). It is specific to Babel 6 and not compatible with Babel 7+. Key differentiators: supports experimental inlining (but warns it may break code), handles hoisted async functions correctly, and properly eliminates repeated var/function declarations.

npm install babel-plugin-transform-dead-code-elimination
INSTALL
IMPORT
SIG · BABEL-PLUGIN-TRANS
B
babel-plugin-transform-dead-code-elimination
devopsjavascriptv2.2.3
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default
import plugin from 'babel-plugin-transform-dead-code-elimination'
const plugin = require('babel-plugin-transform-dead-code-elimination')
This is a Babel plugin, not commonly imported directly; typically used in .babelrc or babel.config.js as a string.

Demonstrates using the plugin to eliminate dead code (unreachable branch and unused variable).

// .babelrc { "plugins": [ "transform-dead-code-elimination" ] } // Input: dead code function example() { if (false) { return 1; } return 2; var x = 3; // unused } // Output: dead code removed function example() { return 2; }
Debug
Known issues
gotchaexperimentalInlining option can break code; use with caution.
fix
Avoid setting experimentalInlining: true unless you thoroughly test output.
affects: >=2.0.0
deprecatedThis plugin is for Babel 6 only. Not compatible with Babel 7+.
fix
Use @babel/plugin-transform-dead-code-elimination or equivalent for Babel 7.
affects: >=2.0.0
gotchaPlugin may incorrectly eliminate hoisted async functions if transform-async-to-generator is not used.
fix
Upgrade to version 2.2.1 or later.
affects: <2.2.1
Errors
Common errors & fixes
Error: Plugin transform-dead-code-elimination requires a Babel 6 version
Using plugin with Babel 7 or later.
fix
Use @babel/plugin-transform-dead-code-elimination for Babel 7.
AssertionError [ERR_ASSERTION]: false == true
Bug with repeated var/function declarations in older versions.
fix
Upgrade to version 2.2.2 or later.
Upgrade
Version history
2.2.3latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
4 hits · last 30 days
node
4
Resources
babel-plugin-transform-dead-code-elimination — npm install babel-plugin-transform-dead-code-elimination · libregistry