Registry / devops / babel-plugin-uglify

babel-plugin-uglify

JSON →
library1.0.2jsnpmunverified

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.

npm install babel-plugin-uglify
INSTALL
IMPORT
SIG · BABEL-PLUGIN-UGLIF
B
babel-plugin-uglify
devopsjavascriptv1.0.2
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

plugin
// In .babelrc: {"plugins": ["uglify:after"]}
{"plugins": ["uglify"]}
Must use ':after' suffix to ensure it runs after ES6 transforms. Without it, UglifyJS may receive untransformed ES6 code and fail.

Shows how to configure babel-plugin-uglify via .babelrc and Node API, including the required ':after' suffix.

// .babelrc example { "plugins": ["uglify:after"] } // Node API example var babel = require('babel'); babel.transform('const x = 1;', { plugins: ['uglify:after'] }, function(err, result) { console.log(result.code); });
Debug
Known issues
deprecatedbabel-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.
fix
Migrate to @babel/plugin-minify (babel-minify) or babel-plugin-terser.
affects: >=1.0.0
breakingThe plugin requires Babel 5.x. It will not work with Babel 6 or later due to AST format changes.
fix
Use Babel 5 or switch to a Babel 6+ compatible minifier.
affects: >=1.0.0
gotchaThe 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.
fix
Add ':after' suffix to plugin name in .babelrc or programmatic options.
affects: >=1.0.0
deprecatedUglifyJS itself is less actively maintained than terser. Consider using terser-based plugins for better ES6+ support and ongoing maintenance.
fix
Use babel-plugin-terser instead of babel-plugin-uglify.
affects: >=1.0.0
Errors
Common errors & fixes
Couldn't find preset "es2015" relative to directory
Missing Babel preset when trying to run transforms before uglify
fix
Install and configure Babel presets (e.g., babel-preset-es2015) in .babelrc or programmatic options.
Unexpected token: name (x)
Plugin ran before ES6 transformers, so UglifyJS encountered ES6 syntax
fix
Ensure plugin is specified with ':after' suffix (e.g., 'uglify:after') so it runs after ES6 transforms.
require('babel').transform is not a function
Using Babel 6+ API with babel-plugin-uglify which is only for Babel 5
fix
Use Babel 5 API (require('babel')) or switch to a Babel 6+ compatible minifier plugin.
Upgrade
Version history
1.0.2latest on npm
Audit
Dependencies
uglify-jsoptionalPeer dependency for minification engine
Agent activity
8 hits · last 30 days
node
6
Resources
babel-plugin-uglify — npm install babel-plugin-uglify · libregistry