{"id":19098,"library":"babel-plugin-minify-dead-code-elimination-while-loop-fixed","title":"babel-plugin-minify-dead-code-elimination-while-loop-fixed","description":"A forked and fixed version of babel-plugin-minify-dead-code-elimination from Babel minify 0.3.x. It inlines bindings, evaluates expressions, and removes unreachable code. This plugin specifically addresses a bug related to while loops (issue #11343). Current stable version: 0.3.1. No regular release cadence; maintained sporadically. Key differentiator: fixes a specific loop elimination bug not present in the original plugin.","status":"active","version":"0.3.1","language":"javascript","source_language":"en","source_url":"https://github.com/kingback/babel-plugin-minify-dead-code-elimination-while-loop-fixed","tags":["javascript","babel-plugin"],"install":[{"cmd":"npm install babel-plugin-minify-dead-code-elimination-while-loop-fixed","lang":"bash","label":"npm"},{"cmd":"yarn add babel-plugin-minify-dead-code-elimination-while-loop-fixed","lang":"bash","label":"yarn"},{"cmd":"pnpm add babel-plugin-minify-dead-code-elimination-while-loop-fixed","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Required for plugin to be loaded and used in Babel transformations.","package":"babel-core","optional":false}],"imports":[{"note":"This package is a CommonJS plugin. Use require() for Node.js/Babel config. ESM import is not supported.","wrong":"import plugin from 'babel-plugin-minify-dead-code-elimination-while-loop-fixed'","symbol":"default","correct":"module.exports = require('babel-plugin-minify-dead-code-elimination-while-loop-fixed')"},{"note":"In .babelrc or babel.config.js, omit the 'babel-plugin-' prefix. Use the short name.","wrong":"{\n  \"plugins\": [\"babel-plugin-minify-dead-code-elimination-while-loop-fixed\"]\n}","symbol":"function","correct":"{\n  \"plugins\": [\"minify-dead-code-elimination-while-loop-fixed\"]\n}"},{"note":"When passing options, the plugin must be specified as an array inside another array. Missing the inner array will cause options to be ignored.","wrong":"{\n  \"plugins\": [\"minify-dead-code-elimination-while-loop-fixed\", { \"keepFnName\": true }]\n}","symbol":"options","correct":"{\n  \"plugins\": [[\"minify-dead-code-elimination-while-loop-fixed\", { \"keepFnName\": true }]]\n}"}],"quickstart":{"code":"// Install the plugin\n// npm install babel-plugin-minify-dead-code-elimination-while-loop-fixed\n\n// .babelrc example\n{\n  \"presets\": [\"@babel/preset-env\"],\n  \"plugins\": [\"minify-dead-code-elimination-while-loop-fixed\"]\n}\n\n// Input code\nfunction foo() { var x = 1; }\nfunction bar() { var x = f(); }\nfunction baz() {\n  var x = 1;\n  console.log(x);\n  function unused() { return 5; }\n}\n\n// After transformation (output)\n// function foo() {}\n// function bar() { f(); }\n// function baz() {\n//   console.log(1);\n// }","lang":"javascript","description":"Shows how to install and configure the plugin in .babelrc, and the effect of dead code elimination."},"warnings":[{"fix":"Upgrade to @babel/core and use @babel/plugin-transform-modules-commonjs or similar. Alternatively, stick with Babel 6.","message":"Plugin uses deprecated babel-core API (babel.transform). May not work with Babel 7+.","severity":"breaking","affected_versions":">=0.3.1"},{"fix":"Ensure Babel is installed and the plugin is declared in the Babel configuration.","message":"Plugin only works as a Babel plugin; it cannot be used standalone.","severity":"gotcha","affected_versions":">=0"},{"fix":"Use the correct array nesting pattern shown in the documentation.","message":"Options must be nested correctly: [[\"minify-dead-code-elimination-while-loop-fixed\", options]].","severity":"gotcha","affected_versions":">=0"},{"fix":"Consider using babel-preset-minify for a comprehensive minification setup.","message":"The original babel-plugin-minify-dead-code-elimination is deprecated in favor of babel-preset-minify.","severity":"deprecated","affected_versions":">=0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Run npm install babel-plugin-minify-dead-code-elimination-while-loop-fixed --save-dev","cause":"Plugin not installed or typo in module name.","error":"Error: Cannot find module 'babel-plugin-minify-dead-code-elimination-while-loop-fixed'"},{"fix":"Use require() in Node.js or configure Babel with the string plugin name in .babelrc.","cause":"Using ESM import instead of require(). The plugin exports via module.exports.","error":"TypeError: The plugin \"minify-dead-code-elimination-while-loop-fixed\" didn't return a function."},{"fix":"Use [[\"minify-dead-code-elimination-while-loop-fixed\", { ... }]] syntax.","cause":"Options not nested correctly in an array.","error":"Error: .babelrc: plugins[0] must be a string or an array of [string, options]"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}