{"id":19312,"library":"babel-preset-minify","title":"babel-preset-minify","description":"Babel preset that bundles all babel-minify plugins for minification. Current stable version is 0.5.2 (last release Sep 2018). This project is part of the babel/minify monorepo, which is now in maintenance mode with no active development. The preset provides a convenient way to apply minification transforms like dead code elimination, constant folding, mangle names, and more via a single preset. Unlike terser or uglify, it operates as a Babel transform, allowing integration with Babel workflows and AST-level optimizations. It supports options to enable/disable individual plugins and has known missing dependency issues.","status":"maintenance","version":"0.5.2","language":"javascript","source_language":"en","source_url":"https://github.com/babel/minify/tree/master/packages/babel-preset-minify","tags":["javascript","babel-minify","babel-preset","minify"],"install":[{"cmd":"npm install babel-preset-minify","lang":"bash","label":"npm"},{"cmd":"yarn add babel-preset-minify","lang":"bash","label":"yarn"},{"cmd":"pnpm add babel-preset-minify","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"CommonJS only; ESM import will fail as package does not export ES modules. Use require() in Node.js.","wrong":"import preset from 'babel-preset-minify'","symbol":"default","correct":"module.exports = require('babel-preset-minify')"},{"note":"In Babel config, use the shorthand 'minify' without the 'babel-preset-' prefix.","wrong":"\"presets\": [\"babel-preset-minify\"]","symbol":"preset declaration","correct":"\"presets\": [\"minify\"] in .babelrc or babel.config.js"},{"note":"You must use the preset through Babel's transform API, not call it directly.","wrong":"const minify = require('babel-preset-minify'); minify(code)","symbol":"Node API usage","correct":"const babel = require('@babel/core'); babel.transform(code, { presets: ['minify'] })"}],"quickstart":{"code":"// Install: npm install babel-preset-minify --save-dev\n\n// Example .babelrc\n{\n  \"presets\": [\n    [\"minify\", {\n      \"mangle\": {\n        \"exclude\": [\"MyCustomError\"]\n      },\n      \"removeConsole\": true,\n      \"keepFnName\": false\n    }]\n  ]\n}\n\n// Node API usage\nconst babel = require('@babel/core');\nconst fs = require('fs');\nconst code = fs.readFileSync('./input.js', 'utf8');\nconst output = babel.transformSync(code, {\n  presets: ['minify']\n});\nfs.writeFileSync('./output.min.js', output.code);\n","lang":"javascript","description":"Demonstrates installation, .babelrc configuration with options, and Node API usage for minifying JavaScript."},"warnings":[{"fix":"Migrate to terser (via @babel/plugin-minify? but prefer standalone) or use babel-plugin-uglify or similar.","message":"babel-minify project is no longer actively maintained. Consider using terser or a more modern minifier.","severity":"deprecated","affected_versions":">=0.5.0"},{"fix":"Upgrade to 0.5.2 or pin to 0.5.0. Also, ensure all peer dependencies are installed (babel-core 6.x).","message":"Missing dependencies in version 0.5.1 causing runtime errors","severity":"breaking","affected_versions":"0.5.1"},{"fix":"Update presets from 'babili' to 'minify' and update package names accordingly.","message":"Renamed from Babili to babel-minify in version 0.2.0. Old import paths and configuration break.","severity":"breaking","affected_versions":"<0.2.0"},{"fix":"Use 'exclude' instead of 'blacklist' in mangle options.","message":"The 'blacklist' option for mangle plugin renamed to 'exclude' in version 0.3.0.","severity":"deprecated","affected_versions":">=0.3.0"},{"fix":"Use require() for Node.js. For bundlers, ensure Babel is configured properly.","message":"Does not support ES modules. Only CommonJS via require(). Using import will fail.","severity":"gotcha","affected_versions":">=0.0.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-preset-minify --save-dev","cause":"Forgot to install the package as devDependency.","error":"Error: Cannot find module 'babel-preset-minify'"},{"fix":"Use \"presets\": [\"minify\"] or \"presets\": [[\"minify\", { options }]]","cause":"Misconfigured Babel presets (e.g., using 'babel-preset-minify' instead of 'minify' or array syntax wrong).","error":"TypeError: Cannot read property 'minify' of undefined"},{"fix":"Replace 'blacklist' with 'exclude' in mangle options.","cause":"Using old 'blacklist' option with babel-preset-minify >= 0.3.0.","error":"ERROR: The 'blacklist' option has been removed. Use 'exclude'."},{"fix":"Do not import babel-preset-minify directly in code; use it only in Babel config.","cause":"Webpack or other bundler trying to import the preset as a module directly.","error":"Module not found: Can't resolve 'babel-preset-minify' in ..."}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}