{"id":20609,"library":"terser-webpack-plugin-legacy","title":"Terser Webpack Plugin Legacy","description":"Terser plugin for webpack 3.x to minify JavaScript using terser. Legacy version (v1.2.5) for webpack 3, maintained separately from the main terser-webpack-plugin which targets webpack 4+. Uses terser for modern ES6+ syntax support compared to uglify-js. Limited to Node >= 6.9.0 and webpack ^3.0.0. Not recommended for new projects; use terser-webpack-plugin (non-legacy) for webpack 4+.","status":"maintenance","version":"1.2.5","language":"javascript","source_language":"en","source_url":"https://github.com/webpack-contrib/terser-webpack-plugin","tags":["javascript","uglify","uglify-js","uglify-es","terser","webpack","webpack-plugin","minification","compress"],"install":[{"cmd":"npm install terser-webpack-plugin-legacy","lang":"bash","label":"npm"},{"cmd":"yarn add terser-webpack-plugin-legacy","lang":"bash","label":"yarn"},{"cmd":"pnpm add terser-webpack-plugin-legacy","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"peer dependency","package":"webpack","optional":false}],"imports":[{"note":"CJS only; no default ESM export in this legacy version.","wrong":"import TerserPlugin from 'terser-webpack-plugin-legacy';","symbol":"TerserPlugin","correct":"const TerserPlugin = require('terser-webpack-plugin-legacy');"},{"note":"Note: package name is terser-webpack-plugin-legacy, not terser-webpack-plugin. Also, it's a default export, not named.","wrong":"const { TerserPlugin } = require('terser-webpack-plugin');","symbol":"TerserPlugin (as named export)","correct":"const { TerserPlugin } = require('terser-webpack-plugin-legacy');"},{"note":"Common mistake: using wrong package name. Ensure version 1.x for webpack 3.","wrong":"new (require('terser-webpack-plugin'))({ cache: true })","symbol":"Plugin options","correct":"new (require('terser-webpack-plugin-legacy'))({ cache: true })"}],"quickstart":{"code":"const TerserPlugin = require('terser-webpack-plugin-legacy');\n\nmodule.exports = {\n  context: __dirname,\n  entry: './src/index.js',\n  output: {\n    path: __dirname + '/dist',\n    filename: 'bundle.js'\n  },\n  optimization: {\n    minimizer: [\n      new TerserPlugin({\n        test: /\\.js(\\?.*)?$/i,\n        cache: true,\n        terserOptions: {\n          compress: {\n            drop_console: true\n          }\n        }\n      })\n    ]\n  }\n};","lang":"javascript","description":"Sets up terser-webpack-plugin-legacy in webpack 3 config with cache enabled and console removal."},"warnings":[{"fix":"Install `terser-webpack-plugin-legacy` and require it as shown.","message":"Package name is `terser-webpack-plugin-legacy`, not `terser-webpack-plugin`. Using the wrong package will install the modern version for webpack 4+.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Upgrade to `terser-webpack-plugin` (non-legacy) for webpack 4+.","message":"Only compatible with webpack ^3.0.0. Will not work with webpack 4+.","severity":"breaking","affected_versions":">=1.0.0"},{"fix":"Use `terser-webpack-plugin` (v4+) for new projects.","message":"Legacy plugin; not actively developed. Consider migrating to the non-legacy version.","severity":"deprecated","affected_versions":">=1.0.0"},{"fix":"Set `cache: false` or a custom path to avoid permission errors.","message":"Default caching to `node_modules/.cache/terser-webpack-plugin` may cause issues in CI.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Add `devtool: 'source-map'` to webpack config.","message":"The `sourceMap` option must be enabled in webpack config for source maps to work.","severity":"gotcha","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":"Run: npm install terser-webpack-plugin-legacy --save-dev","cause":"Incorrect package name; installed the wrong package or not installed.","error":"Module not found: Error: Can't resolve 'terser-webpack-plugin'"},{"fix":"Use terser-webpack-plugin (non-legacy) for webpack 4+.","cause":"Plugin incompatible with webpack 4+ because it uses webpack 3 hooks.","error":"TypeError: Cannot read property 'tapAsync' of undefined"},{"fix":"Use TerserPlugin from 'terser-webpack-plugin-legacy' instead.","cause":"Misunderstanding: using UglifyJsPlugin when terser plugin should be used.","error":"Error: webpack.optimize.UglifyJsPlugin is not a constructor"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}