Registry / devops / swc-minify-webpack-plugin

swc-minify-webpack-plugin

JSON →
library2.1.3jsnpmunverified

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.

npm install swc-minify-webpack-plugin
INSTALL
IMPORT
SIG · SWC-MINIFY-WEBPACK
S
swc-minify-webpack-plugin
devopsjavascriptv2.1.3
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.

SwcMinifyWebpackPlugin
import { SwcMinifyWebpackPlugin } from 'swc-minify-webpack-plugin'
import SwcMinifyWebpackPlugin from 'swc-minify-webpack-plugin'
v2.0.0 changed default export to named export. ESM and CJS both use named export.
SwcMinifyWebpackPlugin
const { SwcMinifyWebpackPlugin } = require('swc-minify-webpack-plugin')
const SwcMinifyWebpackPlugin = require('swc-minify-webpack-plugin')
CJS require must destructure the named export. In v1, default export was used.

Basic usage of swc-minify-webpack-plugin as the sole minimizer in webpack's optimization configuration.

// webpack.config.js const { SwcMinifyWebpackPlugin } = require('swc-minify-webpack-plugin'); module.exports = { optimization: { minimize: true, minimizer: [new SwcMinifyWebpackPlugin()], }, };
Debug
Known issues
breakingv2.0.0: Changed default export to named export. Import must use destructuring.
fix
Change `import SwcMinifyWebpackPlugin from 'swc-minify-webpack-plugin'` to `import { SwcMinifyWebpackPlugin } from 'swc-minify-webpack-plugin'`
affects: >=2.0.0
deprecatedv1.x: The default export pattern is deprecated and will not work with v2.
fix
Upgrade to v2 and use named export.
affects: 1.x
gotchaConfiguration options `compress`, `mangle`, and `format` are passed directly to swc.minify(). Incorrect options may silently fail or produce unexpected output.
fix
Refer to swc documentation for valid options: https://swc.rs/docs/configuration/minification
affects: >=1.0.0
Errors
Common errors & fixes
Error: Cannot find module 'swc-minify-webpack-plugin'
Package not installed or incorrect import path.
fix
Run `npm install -D swc-minify-webpack-plugin` and ensure import uses require or import correctly.
TypeError: SwcMinifyWebpackPlugin is not a constructor
Using default import instead of named import in v2.
fix
Use named import: `import { SwcMinifyWebpackPlugin } from 'swc-minify-webpack-plugin'`
ValidationError: Invalid options object. Minimizer Plugin has been initialized using an options object that does not match the API schema.
Incorrect options passed to SwcMinifyWebpackPlugin constructor.
fix
Check options: only `compress`, `mangle`, and `format` are supported. Pass them as an object: `new SwcMinifyWebpackPlugin({ compress: false })`
Upgrade
Version history
2.1.3latest on npm
Audit
Dependencies
@swc/corerequiredpeer dependency - provides the swc compiler for minification
webpackrequiredpeer dependency - plugin runs within webpack 5+
Agent activity
5 hits · last 30 days
node
4
Resources
swc-minify-webpack-plugin — npm install swc-minify-webpack-plugin · libregistry