{"id":19237,"library":"babel-plugin-uglify","title":"babel-plugin-uglify","description":"Babel plugin that integrates UglifyJS minification directly into the Babel pipeline without needing to generate and re-parse code. v1.0.2 is the latest stable release. This plugin works on the Mozilla AST (SpiderMonkey format) used internally by Babel, avoiding repeated code generation and parsing. It is intended for Babel 5.x only, as Babel 6+ uses different AST formats. No longer actively maintained; alternatives include babel-minify (babili) or terser-based plugins. Key differentiator: direct AST-level minification preserves source maps and avoids overhead of stringifying and re-parsing code.","status":"deprecated","version":"1.0.2","language":"javascript","source_language":"en","source_url":"https://github.com/rreverser/babel-plugin-uglify","tags":["javascript","babel-plugin","uglify","minify"],"install":[{"cmd":"npm install babel-plugin-uglify","lang":"bash","label":"npm"},{"cmd":"yarn add babel-plugin-uglify","lang":"bash","label":"yarn"},{"cmd":"pnpm add babel-plugin-uglify","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Peer dependency for minification engine","package":"uglify-js","optional":true}],"imports":[{"note":"Must use ':after' suffix to ensure it runs after ES6 transforms. Without it, UglifyJS may receive untransformed ES6 code and fail.","wrong":"{\"plugins\": [\"uglify\"]}","symbol":"plugin","correct":"// In .babelrc: {\"plugins\": [\"uglify:after\"]}"}],"quickstart":{"code":"// .babelrc example\n{\n  \"plugins\": [\"uglify:after\"]\n}\n\n// Node API example\nvar babel = require('babel');\nbabel.transform('const x = 1;', {\n  plugins: ['uglify:after']\n}, function(err, result) {\n  console.log(result.code);\n});","lang":"javascript","description":"Shows how to configure babel-plugin-uglify via .babelrc and Node API, including the required ':after' suffix."},"warnings":[{"fix":"Migrate to @babel/plugin-minify (babel-minify) or babel-plugin-terser.","message":"babel-plugin-uglify is deprecated. Babel 6+ does not use Mozilla AST, and this plugin is incompatible. Use babel-minify (babili) or plugins based on terser.","severity":"deprecated","affected_versions":">=1.0.0"},{"fix":"Use Babel 5 or switch to a Babel 6+ compatible minifier.","message":"The plugin requires Babel 5.x. It will not work with Babel 6 or later due to AST format changes.","severity":"breaking","affected_versions":">=1.0.0"},{"fix":"Add ':after' suffix to plugin name in .babelrc or programmatic options.","message":"The plugin must be specified with ':after' suffix (e.g., 'uglify:after') in Babel plugins list; otherwise it runs before ES6 transforms and UglifyJS will fail on ES6 syntax.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Use babel-plugin-terser instead of babel-plugin-uglify.","message":"UglifyJS itself is less actively maintained than terser. Consider using terser-based plugins for better ES6+ support and ongoing maintenance.","severity":"deprecated","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Install and configure Babel presets (e.g., babel-preset-es2015) in .babelrc or programmatic options.","cause":"Missing Babel preset when trying to run transforms before uglify","error":"Couldn't find preset \"es2015\" relative to directory"},{"fix":"Ensure plugin is specified with ':after' suffix (e.g., 'uglify:after') so it runs after ES6 transforms.","cause":"Plugin ran before ES6 transformers, so UglifyJS encountered ES6 syntax","error":"Unexpected token: name (x)"},{"fix":"Use Babel 5 API (require('babel')) or switch to a Babel 6+ compatible minifier plugin.","cause":"Using Babel 6+ API with babel-plugin-uglify which is only for Babel 5","error":"require('babel').transform is not a function"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}