unplugin-swc v1.5.9 is a build tool plugin that integrates SWC (Speedy Web Compiler) into Vite and Rollup pipelines. It automatically infers SWC options from tsconfig.json, simplifying migration from Babel/tsc. Released under MIT, actively maintained with frequent updates (monthly releases). Key differentiator: it replaces esbuild in Vite automatically, supports minification in Rollup, and recognizes .mts files (v1.5+). Peer dependency on @swc/core ^1.2.108.
npm install unplugin-swcVerified import paths — ran on the pinned version, not inferred.
Minimal Vite configuration using unplugin-swc with tsconfig inference and optional minification.
Use import syntax and set type: module in package.json.
Switch to import statements.
Only enable minify for Rollup builds; for Vite, use esbuild minify configuration directly.
Use .swcrc for jsc options, or set tsconfigFile: false to disable tsconfig inference.
Adjust include/exclude patterns if needed; .mts is now included by default.
If you don't need keepClassNames, set tsconfigFile: false and configure SWC manually.
Run: npm install unplugin-swc @swc/core -D
Use: import swc from 'unplugin-swc'
Remove minify option from Vite plugin, or use Rollup plugin if minification needed.
Ensure plugin is added to the plugins array: swc.vite() for Vite or swc.rollup() for Rollup.