Skip to content

Upgrading terser-webpack-plugin 4 to 5

Breaking4.2.3 → 5.6.1Breaking7Deprecated1New12Changed5Fixed31Other2

BreakingUpgrade verdict

6 breaking changes.

  • The package's type definitions are now written in a different format, which changes how TypeScript users import its types.
  • If you relied on the plugin's built-in type definitions for optional dependencies, you now need to supply those option types yourself.
  • If you installed the separate @types/terser-webpack-plugin package for TypeScript support, remove it because the plugin now ships its own types and the old ones are wrong.
  • This version no longer works with webpack 4; you must use webpack 5.
Top 4 of 7 that need code or config changes

Adds @jridgewell/trace-mapping ^0.3.25.

Drops cacache, find-cache-dir, p-limit, serialize-javascript, source-map, webpack-sources.

Installs 26 packages in all (was 83).

Breaking6
Removes the CommonJS wrapper and generates types in CommonJS format using export = and namespaces, so exported types can be used directly.
Removes types for optional dependencies in favor of developer-provided options, a potential breaking change for types due to invalid usage.
Built-in TypeScript types replace @types/terser-webpack-plugin, which is incompatible and should no longer be used.
@types/terser-webpack-plugin
Drops support for webpack@4.
Removes the cache option; webpack's cache option is respected by default.
cachecacheKeys
Removes the sourceMap option; webpack's devtool option is respected by default.
sourceMapdevtool
Deprecated1
Renames terserOptions to minimizerOptions; terserOptions remains as a deprecated alias.
terserOptionsminimizerOptions