{"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,"search_vec":"'0.5.2':20 '2018':24 'activ':41 'allow':77 'appli':50 'ast':84 'ast-level':83 'babel':2,5,11,75,80,102,105 'babel-minifi':10,101 'babel-preset':104 'babel-preset-minifi':1 'babel/minify':31 'bundl':8 'code':55 'constant':57 'conveni':47 'current':16 'dead':54 'depend':98 'develop':42 'elimin':56 'enable/disable':91 'fold':58 'individu':92 'integr':78 'issu':99 'javascript':100 'known':96 'last':21 'level':85 'like':53 'mainten':37 'mangl':59 'minif':15,51 'minifi':4,12,103,107 'miss':97 'mode':38 'monorepo':32 'name':60 'oper':72 'optim':86 'option':89 'part':28 'plugin':13,93 'preset':3,6,44,66,106 'project':26 'provid':45 'releas':22 'sep':23 'singl':65 'stabl':17 'support':88 'terser':68 'transform':52,76 'uglifi':70 'unlik':67 'version':18 'via':63 'way':48 'workflow':81","created_at":"2026-04-25T11:17:08.837101+00:00","updated_at":"2026-04-25T11:17:08.837101+00:00","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,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":"","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/babel/minify","docs":null,"changelog":null,"pypi":null,"npm":"https://www.npmjs.com/package/babel-preset-minify","openapi_spec":null,"status_page":null,"smithery":null,"categories":["devops"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-17","next_check":"2026-07-24","install_tag":null}}