{"id":26599,"library":"vite-plugin-swc-react","title":"Vite Plugin SWC React","description":"A Vite plugin that replaces Babel with SWC for fast React JSX transform, HMR, and optional polyfill/transpile via SWC's preset-env. Current version 0.1.12 has no recent updates; peer dependencies are @swc/core ^1.2.98 and Vite ^2.6.7+. It offers similar features to @vitejs/plugin-react but uses SWC for faster compilation. Differentiators include built-in polyfill mode and classic JSX runtime support. Release cadence is unknown (last update likely 2022).","status":"maintenance","version":"0.1.12","language":"javascript","source_language":"en","source_url":null,"tags":["javascript","vite","react","swc","vite react"],"install":[{"cmd":"npm install vite-plugin-swc-react","lang":"bash","label":"npm"},{"cmd":"yarn add vite-plugin-swc-react","lang":"bash","label":"yarn"},{"cmd":"pnpm add vite-plugin-swc-react","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Required peer dependency for SWC compilation","package":"@swc/core","optional":false},{"reason":"Required peer dependency; only compatible with Vite 2","package":"vite","optional":false}],"imports":[{"note":"ESM-only; CommonJS require() will fail in Vite's ESM context.","wrong":"const swcReact = require('vite-plugin-swc-react')","symbol":"default","correct":"import swcReact from 'vite-plugin-swc-react'"},{"note":"Package exports default export, not named.","wrong":"const { swcReact } = require('vite-plugin-swc-react')","symbol":"swcReact","correct":"import swcReact from 'vite-plugin-swc-react'"},{"note":"Types are attached to default export; no separate type export.","wrong":"import { VitePluginSwcReact } from 'vite-plugin-swc-react'","symbol":"type definitions","correct":"import swcReact from 'vite-plugin-swc-react'"}],"quickstart":{"code":"import { defineConfig } from 'vite';\nimport swcReact from 'vite-plugin-swc-react';\n\nexport default defineConfig({\n  plugins: [\n    swcReact()\n  ]\n});","lang":"typescript","description":"Configure Vite to use SWC for React JSX transform, replacing the default Babel-based plugin."},"warnings":[{"fix":"Use @vitejs/plugin-react-swc or vite-plugin-swc-react-refresh instead, or downgrade Vite to ^2.6.7.","message":"Package is compatible only with Vite 2, not Vite 3+ or 4+. Installing on newer Vite versions will cause errors.","severity":"breaking","affected_versions":">=0.1.0"},{"fix":"Set swcReact({ reactFresh: false }) in plugin config.","message":"HMR (React Refresh) is enabled by default but can be disabled via `reactFresh: false`. If HMR fails, try disabling it.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Install npm install -D browserslist && npm install core-js","message":"When using polyfill mode, you must install both `browserslist` (devDep) and `core-js` (dep) manually. Missing them causes runtime errors.","severity":"gotcha","affected_versions":">=0.1.0"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Use @vitejs/plugin-react-swc for Vite 3+","cause":"Package only supports Vite 2 peer dep.","error":"Error: The plugin 'vite:react-swc' is not compatible with Vite 3"},{"fix":"npm install core-js && npm install -D browserslist","cause":"Missing required dependencies for polyfill mode.","error":"Cannot find module 'core-js' or 'browserslist' while using polyfill"},{"fix":"Ensure vite-plugin-swc-react is added to plugins array and Vite version is 2.x.","cause":"JSX not transformed when plugin not properly configured or Vite version mismatch.","error":"Module parse failed: Unexpected token (1:14) - 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}