{"id":22524,"library":"unplugin-swc","title":"unplugin-swc","description":"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.","status":"active","version":"1.5.9","language":"javascript","source_language":"en","source_url":"https://github.com/unplugin/unplugin-swc","tags":["javascript","typescript"],"install":[{"cmd":"npm install unplugin-swc","lang":"bash","label":"npm"},{"cmd":"yarn add unplugin-swc","lang":"bash","label":"yarn"},{"cmd":"pnpm add unplugin-swc","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"peer dependency: required at runtime for SWC compilation","package":"@swc/core","optional":false}],"imports":[{"note":"ESM-only; CommonJS require fails as package is ESM-only since v1.5","wrong":"const swc = require('unplugin-swc')","symbol":"default (swc)","correct":"import swc from 'unplugin-swc'"},{"note":"Function name is lowercase; case-sensitive","wrong":"swc.Vite()","symbol":"vite plugin","correct":"swc.vite()"},{"note":"Function name is lowercase; case-sensitive","wrong":"swc.Rollup()","symbol":"rollup plugin","correct":"swc.rollup()"},{"note":"TypeScript type exported; for type-checking only","wrong":null,"symbol":"Options type","correct":"import type { Options } from 'unplugin-swc'"}],"quickstart":{"code":"import swc from 'unplugin-swc'\nimport { defineConfig } from 'vite'\n\nexport default defineConfig({\n  plugins: [\n    swc.vite({\n      tsconfigFile: './tsconfig.json',\n      include: /\\.[jt]sx?$/,\n      exclude: /node_modules/,\n      minify: process.env.NODE_ENV === 'production'\n    })\n  ]\n})","lang":"typescript","description":"Minimal Vite configuration using unplugin-swc with tsconfig inference and optional minification."},"warnings":[{"fix":"Use import syntax and set type: module in package.json.","message":"Package is ESM-only since v1.5.1; requires 'type': 'module' in package.json or .mjs extension.","severity":"breaking","affected_versions":">=1.5.1"},{"fix":"Switch to import statements.","message":"Using require('unplugin-swc') is deprecated; ESM-only from v1.5.1 onward.","severity":"deprecated","affected_versions":">=1.5.1"},{"fix":"Only enable minify for Rollup builds; for Vite, use esbuild minify configuration directly.","message":"The minify option only works with Rollup, not Vite (Vite uses esbuild for minification and cannot be changed).","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Use .swcrc for jsc options, or set tsconfigFile: false to disable tsconfig inference.","message":"Setting jsc options in plugin options may conflict with .swcrc or tsconfig.json inference. It's recommended to configure jsc in .swcrc instead.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Adjust include/exclude patterns if needed; .mts is now included by default.","message":"In version 1.5.0, .mts files are now recognized; if you relied on previous behavior of ignoring .mts, update your include/exclude regex.","severity":"breaking","affected_versions":">=1.5.0"},{"fix":"If you don't need keepClassNames, set tsconfigFile: false and configure SWC manually.","message":"When using experimentalDecorators, jsc.keepClassNames is automatically enabled; this may affect class naming in production builds.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Run: npm install unplugin-swc @swc/core -D","cause":"Missing peer dependency @swc/core or wrong package manager cache.","error":"Cannot find module 'unplugin-swc'"},{"fix":"Use: import swc from 'unplugin-swc'","cause":"Using CommonJS require() instead of ESM import.","error":"TypeError: swc.vite is not a function"},{"fix":"Remove minify option from Vite plugin, or use Rollup plugin if minification needed.","cause":"Using minify: true for Vite plugin, which is unsupported.","error":"Error: [unplugin-swc] 'minify' only works with rollup"},{"fix":"Ensure plugin is added to the plugins array: swc.vite() for Vite or swc.rollup() for Rollup.","cause":"unplugin-swc is not correctly included in Vite/Rollup configuration; often due to missing plugin registration.","error":"Module parse failed: Unexpected token (1:0) You may need an appropriate loader to handle this file type."}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}