{"id":19185,"library":"babel-plugin-transform-dead-code-elimination","title":"babel-plugin-transform-dead-code-elimination","description":"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.","status":"deprecated","version":"2.2.3","language":"javascript","source_language":"en","source_url":"https://github.com/erikdesjardins/babel-plugin-transform-dead-code-elimination","tags":["javascript","babel-plugin"],"install":[{"cmd":"npm install babel-plugin-transform-dead-code-elimination","lang":"bash","label":"npm"},{"cmd":"yarn add babel-plugin-transform-dead-code-elimination","lang":"bash","label":"yarn"},{"cmd":"pnpm add babel-plugin-transform-dead-code-elimination","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"This is a Babel plugin, not commonly imported directly; typically used in .babelrc or babel.config.js as a string.","wrong":"const plugin = require('babel-plugin-transform-dead-code-elimination')","symbol":"default","correct":"import plugin from 'babel-plugin-transform-dead-code-elimination'"}],"quickstart":{"code":"// .babelrc\n{\n  \"plugins\": [\n    \"transform-dead-code-elimination\"\n  ]\n}\n\n// Input: dead code\nfunction example() {\n  if (false) {\n    return 1;\n  }\n  return 2;\n  var x = 3; // unused\n}\n\n// Output: dead code removed\nfunction example() {\n  return 2;\n}","lang":"javascript","description":"Demonstrates using the plugin to eliminate dead code (unreachable branch and unused variable)."},"warnings":[{"fix":"Avoid setting experimentalInlining: true unless you thoroughly test output.","message":"experimentalInlining option can break code; use with caution.","severity":"gotcha","affected_versions":">=2.0.0"},{"fix":"Use @babel/plugin-transform-dead-code-elimination or equivalent for Babel 7.","message":"This plugin is for Babel 6 only. Not compatible with Babel 7+.","severity":"deprecated","affected_versions":">=2.0.0"},{"fix":"Upgrade to version 2.2.1 or later.","message":"Plugin may incorrectly eliminate hoisted async functions if transform-async-to-generator is not used.","severity":"gotcha","affected_versions":"<2.2.1"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Use @babel/plugin-transform-dead-code-elimination for Babel 7.","cause":"Using plugin with Babel 7 or later.","error":"Error: Plugin transform-dead-code-elimination requires a Babel 6 version"},{"fix":"Upgrade to version 2.2.2 or later.","cause":"Bug with repeated var/function declarations in older versions.","error":"AssertionError [ERR_ASSERTION]: false == true"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}