{"id":20599,"library":"swc-minify-webpack-plugin","title":"swc-minify-webpack-plugin","description":"A webpack plugin that uses swc.minify() to minify JavaScript bundles, offering faster performance than terser-webpack-plugin's swc mode. Current stable version is 2.1.3, released under Apache 2.0 license. It provides simpler options, enables mangle by default for better compression, and is a fork of swc-webpack-plugin with improved performance by using swc.minify() instead of swc.transform(). Requires webpack 5+ and @swc/core 1+ as peer dependencies. Ships TypeScript type definitions.","status":"active","version":"2.1.3","language":"javascript","source_language":"en","source_url":"ssh://git@github.com/guoyunhe/swc-minify-webpack-plugin","tags":["javascript","webpack","plugin","minify","uglify","optimization","bundle","build","compile","typescript"],"install":[{"cmd":"npm install swc-minify-webpack-plugin","lang":"bash","label":"npm"},{"cmd":"yarn add swc-minify-webpack-plugin","lang":"bash","label":"yarn"},{"cmd":"pnpm add swc-minify-webpack-plugin","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"peer dependency - provides the swc compiler for minification","package":"@swc/core","optional":false},{"reason":"peer dependency - plugin runs within webpack 5+","package":"webpack","optional":false}],"imports":[{"note":"v2.0.0 changed default export to named export. ESM and CJS both use named export.","wrong":"import SwcMinifyWebpackPlugin from 'swc-minify-webpack-plugin'","symbol":"SwcMinifyWebpackPlugin","correct":"import { SwcMinifyWebpackPlugin } from 'swc-minify-webpack-plugin'"},{"note":"CJS require must destructure the named export. In v1, default export was used.","wrong":"const SwcMinifyWebpackPlugin = require('swc-minify-webpack-plugin')","symbol":"SwcMinifyWebpackPlugin","correct":"const { SwcMinifyWebpackPlugin } = require('swc-minify-webpack-plugin')"}],"quickstart":{"code":"// webpack.config.js\nconst { SwcMinifyWebpackPlugin } = require('swc-minify-webpack-plugin');\n\nmodule.exports = {\n  optimization: {\n    minimize: true,\n    minimizer: [new SwcMinifyWebpackPlugin()],\n  },\n};\n","lang":"javascript","description":"Basic usage of swc-minify-webpack-plugin as the sole minimizer in webpack's optimization configuration."},"warnings":[{"fix":"Change `import SwcMinifyWebpackPlugin from 'swc-minify-webpack-plugin'` to `import { SwcMinifyWebpackPlugin } from 'swc-minify-webpack-plugin'`","message":"v2.0.0: Changed default export to named export. Import must use destructuring.","severity":"breaking","affected_versions":">=2.0.0"},{"fix":"Upgrade to v2 and use named export.","message":"v1.x: The default export pattern is deprecated and will not work with v2.","severity":"deprecated","affected_versions":"1.x"},{"fix":"Refer to swc documentation for valid options: https://swc.rs/docs/configuration/minification","message":"Configuration options `compress`, `mangle`, and `format` are passed directly to swc.minify(). Incorrect options may silently fail or produce unexpected output.","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 -D swc-minify-webpack-plugin` and ensure import uses require or import correctly.","cause":"Package not installed or incorrect import path.","error":"Error: Cannot find module 'swc-minify-webpack-plugin'"},{"fix":"Use named import: `import { SwcMinifyWebpackPlugin } from 'swc-minify-webpack-plugin'`","cause":"Using default import instead of named import in v2.","error":"TypeError: SwcMinifyWebpackPlugin is not a constructor"},{"fix":"Check options: only `compress`, `mangle`, and `format` are supported. Pass them as an object: `new SwcMinifyWebpackPlugin({ compress: false })`","cause":"Incorrect options passed to SwcMinifyWebpackPlugin constructor.","error":"ValidationError: Invalid options object. Minimizer Plugin has been initialized using an options object that does not match the API schema."}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}