{"id":26774,"library":"babel-minify","title":"babel-minify (formerly Babili)","description":"An ES6+ aware JavaScript minifier based on the Babel toolchain. Current stable version is 0.5.2, released in 2018. Development has been stalled since then; it is effectively in maintenance mode. Unlike traditional minifiers (UglifyJS, Terser), babel-minify operates on an AST that can understand modern ES6+ syntax, allowing it to minify code without needing to down-compile first. It works as a standalone CLI tool or as a Babel preset. Note: it is deprecated in favor of Terser for most use cases because Babel itself stopped maintaining it.","status":"maintenance","version":"0.5.2","language":"javascript","source_language":"en","source_url":"https://github.com/babel/minify/tree/master/packages/babel-minify","tags":["javascript","babel-minify","babel-preset","minify"],"install":[{"cmd":"npm install babel-minify","lang":"bash","label":"npm"},{"cmd":"yarn add babel-minify","lang":"bash","label":"yarn"},{"cmd":"pnpm add babel-minify","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"babel-minify is a wrapper around the minify preset; used internally.","package":"babel-preset-minify","optional":false}],"imports":[{"note":"babel-minify does not ship ES module exports; use CommonJS require. The default export is a function.","wrong":"import minify from 'babel-minify';","symbol":"minify","correct":"const minify = require('babel-minify');"},{"note":"There is no named export 'minify'; the default export is the function. In some bundlers, .default may be needed.","wrong":"const minify = require('babel-minify').minify;","symbol":"minify","correct":"const minify = require('babel-minify').default || require('babel-minify');"},{"note":"babel-minify does not expose a transform function; use @babel/core for full Babel transformations.","wrong":"const { transform } = require('babel-minify');","symbol":"transform","correct":"const { transform } = require('@babel/core');"}],"quickstart":{"code":"const minify = require('babel-minify');\nconst inputCode = `function hello(name) { console.log('Hello, ' + name); }`;\nconst options = {\n  mangle: { keepClassName: true },\n  deadcode: { keepFnArgs: false }\n};\ntry {\n  const { code, map } = minify(inputCode, options);\n  console.log('Minified code:', code);\n} catch (err) {\n  console.error('Minification failed:', err);\n}","lang":"javascript","description":"Demonstrates basic usage of babel-minify Node API with mangling and dead code elimination options."},"warnings":[{"fix":"Switch to terser for active development and bug fixes.","message":"babel-minify is no longer actively maintained; Babel recommends using Terser for minification.","severity":"deprecated","affected_versions":">=0.5.0"},{"fix":"Update code to use new API; refer to changelog.","message":"Breaking change in 0.4.0: significant API overhaul; compatibility with older babel versions dropped.","severity":"breaking","affected_versions":">=0.4.0 <0.5.0"},{"fix":"Replace 'babili' requires with 'babel-minify'.","message":"Renamed from Babili to babel-minify in 0.2.0; package name changed.","severity":"breaking","affected_versions":">=0.2.0"},{"fix":"Use CommonJS require; if using ESM, consider dynamic import or use Terser.","message":"Does not support ES module imports; must use require() or configure bundler accordingly.","severity":"gotcha","affected_versions":"*"},{"fix":"Upgrade to 0.5.2 or manually install missing peer dependencies like @babel/core.","message":"Missing dependencies in versions 0.5.0 and 0.5.1 causing installation failures.","severity":"gotcha","affected_versions":">=0.5.0 <=0.5.1"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Upgrade to babel-minify@0.5.2 or install missing plugins manually.","cause":"Missing dependency in babel-minify 0.5.0/0.5.1; the package didn't declare all dependencies.","error":"Error: Cannot find module 'babel-plugin-minify-dead-code-elimination'"},{"fix":"Use `const minify = require('babel-minify');` or in ESM: `import minify from 'babel-minify';` with proper bundler handling.","cause":"Using ES module import (import minify from 'babel-minify') which returns an object with default property, not the function directly.","error":"TypeError: minify is not a function"},{"fix":"Install babel-preset-minify explicitly: npm install babel-preset-minify --save-dev","cause":"babel-preset-minify is a peer dependency not automatically installed; missing or wrong version.","error":"Error: Preset babel-preset-minify not found."},{"fix":"Ensure input file path is correct and use --out-file for output.","cause":"CLI command invoked without specifying input file correctly or file does not exist.","error":"ENOENT: no such file or directory, open 'input.js'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}