{"id":20611,"library":"terser-webpack-plugin","title":"terser-webpack-plugin","description":"Webpack plugin that uses Terser to minify/minimize JavaScript output. Current stable version 5.5.0, with frequent releases (multiple per year). Ships TypeScript definitions. Key differentiator: integrates deeply with webpack's optimization pipeline, supports source maps, parallelization via worker threads, and custom minimizers (e.g., swc, esbuild). Requires webpack ^5.1.0. Active maintenance by webpack team.","status":"active","version":"5.5.0","language":"javascript","source_language":"en","source_url":"https://github.com/webpack/terser-webpack-plugin","tags":["javascript","uglify","uglify-js","uglify-es","terser","webpack","webpack-plugin","minification","compress","typescript"],"install":[{"cmd":"npm install terser-webpack-plugin","lang":"bash","label":"npm"},{"cmd":"yarn add terser-webpack-plugin","lang":"bash","label":"yarn"},{"cmd":"pnpm add terser-webpack-plugin","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"peer dependency required for plugin functionality","package":"webpack","optional":true}],"imports":[{"note":"CommonJS import is standard; ESM named export exists but is unconventional.","wrong":"import TerserPlugin from 'terser-webpack-plugin';","symbol":"TerserPlugin","correct":"const TerserPlugin = require('terser-webpack-plugin');"},{"note":"Default export only. No named export for TerserPlugin.","wrong":"import { TerserPlugin } from 'terser-webpack-plugin';","symbol":"TerserPlugin (ESM)","correct":"import TerserPlugin from 'terser-webpack-plugin';"},{"note":"Type import for options type.","symbol":"TerserPluginOptions (TypeScript)","correct":"import type { TerserPluginOptions } from 'terser-webpack-plugin';"}],"quickstart":{"code":"const TerserPlugin = require('terser-webpack-plugin');\n\nmodule.exports = {\n  optimization: {\n    minimize: true,\n    minimizer: [\n      new TerserPlugin({\n        terserOptions: {\n          compress: { drop_console: true },\n          output: { comments: false },\n        },\n        extractComments: false,\n        parallel: true,\n      }),\n    ],\n  },\n};","lang":"javascript","description":"Basic webpack configuration with TerserPlugin for JS minification, dropping console statements and comments."},"warnings":[{"fix":"Set devtool to 'source-map', 'inline-source-map', 'hidden-source-map', or 'nosources-source-map'.","message":"Using 'eval' devtool prevents source map generation; use 'source-map' instead.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Set parallel to explicit number (e.g., 2) or false in CI environments.","message":"Parallelism defaults to os.cpus().length - 1; fails on Circle CI due to CPU limit.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"For webpack v5, install terser-webpack-plugin only if you want to override default options.","message":"Webpack v5 includes terser-webpack-plugin out of the box; manual install only needed for customization.","severity":"breaking","affected_versions":">=5.0.0"},{"fix":"Set extractComments: false or extractComments: true in options to avoid deprecation warnings.","message":"Since v5.3.11, extraction of comments by default may change; set extractComments explicitly.","severity":"deprecated","affected_versions":">=5.3.11"},{"fix":"Upgrade to v5.3.16 or higher.","message":"Empty files in source map processing cause errors prior to v5.3.16.","severity":"gotcha","affected_versions":"<5.3.16"},{"fix":"Use v4.x of this plugin for webpack v4, or v5.x for webpack v5.","message":"v1.x only supports webpack v4; v5.x only supports webpack v5.","severity":"breaking","affected_versions":">=1.0.0 <2.0.0 || >=5.0.0"},{"fix":"For swcMinify support, use v5.5.0+ and set minify: TerserPlugin.swcMinify.","message":"Custom minimizer like swcMinify requires 'experimental' flag before v5.5.0.","severity":"gotcha","affected_versions":"<5.5.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Set parallel: false or parallel: 2 in plugin options.","cause":"Circle CI reports fewer CPUs than available, causing worker thread overload.","error":"Error: Call retries were exceeded (with parallel: true on Circle CI)"},{"fix":"Update to v5.3.16+ or filter out empty files.","cause":"TerserPlugin fails on empty JavaScript files when source maps are enabled.","error":"TypeError: Cannot read properties of undefined (reading 'source')"},{"fix":"Run 'npm install terser-webpack-plugin --save-dev'","cause":"Plugin not installed or installed as devDependency but used in non-dev context.","error":"Module not found: Error: Can't resolve 'terser-webpack-plugin' in ..."},{"fix":"Use 'const TerserPlugin = require('terser-webpack-plugin')' or ESM default import.","cause":"Using import type incorrectly; TerserPlugin is a class, not a type.","error":"TypeScript error: 'TerserPlugin' cannot be used as a value because it is a type."},{"fix":"Set extractComments: false or extractComments: true in plugin options.","cause":"Default behavior for extractComments changed; explicit option required.","error":"Warning: TerserWebpackPlugin: options.extractComments is deprecated."}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}