# Changelog ## Unreleased ### Add `compiler` option [#1461](https://github.com/vitejs/vite-plugin-react/pull/1461) Add `compiler` option to enable the React Compiler. Fixes [#428](https://github.com/vitejs/vite-plugin-react/issues/428). ```ts react({ compiler: true }) ``` ## 4.3.3 (2026-07-30) ### Add a patch for bundled-dev mode compat [#1352](https://github.com/vitejs/vite-plugin-react/pull/1352) Added a patch so that this plugin works with [the experimental bundled dev mode](https://vite.dev/blog/announcing-vite8-1#experimental-bundled-dev-mode). Note that because this Vite feature is experimental, compatibility in future Vite releases is not guaranteed. ## 4.3.2 (2026-07-22) ### Don't apply React Refresh wrapper for non JSX files [#1226](https://github.com/vitejs/vite-plugin-react/pull/1226) Fixes [#1225](https://github.com/vitejs/vite-plugin-react/issues/1225). ## 4.3.1 (2026-05-14) ### Avoid `esbuild` warnings with Vite 8 [#1195](https://github.com/vitejs/vite-plugin-react/pull/1195) Fixes [#1187](https://github.com/vitejs/vite-plugin-react/issues/1187). ## 4.3.0 (2026-03-12) ### Add Vite 8 to peerDependencies range [#1142](https://github.com/vitejs/vite-plugin-react/pull/1142) This plugin is compatible with Vite 8. ## 4.2.3 (2026-02-02) ## 4.2.2 (2025-11-12) ### Update code to support newer `rolldown-vite` ([#978](https://github.com/vitejs/vite-plugin-react/pull/978)) `rolldown-vite` will remove `optimizeDeps.rollupOptions` in favor of `optimizeDeps.rolldownOptions` soon. This plugin now uses `optimizeDeps.rolldownOptions` to support newer `rolldown-vite`. Please update `rolldown-vite` to the latest version if you are using an older version. ## 4.2.1 (2025-11-05) ### Fix `@vitejs/plugin-react-swc/preamble` on build ([#962](https://github.com/vitejs/vite-plugin-react/pull/962)) ## 4.2.0 (2025-10-24) ### Add `@vitejs/plugin-react-swc/preamble` virtual module for SSR HMR ([#890](https://github.com/vitejs/vite-plugin-react/pull/890)) SSR applications can now initialize HMR runtime by importing `@vitejs/plugin-react-swc/preamble` at the top of their client entry instead of manually calling `transformIndexHtml`. This simplifies SSR setup for applications that don't use the `transformIndexHtml` API. ### Use SWC when useAtYourOwnRisk_mutateSwcOptions is provided ([#951](https://github.com/vitejs/vite-plugin-react/pull/951)) Previously, this plugin did not use SWC if plugins were not provided even if `useAtYourOwnRisk_mutateSwcOptions` was provided. This is now fixed. ## 4.1.0 (2025-09-17) ### Set SWC cacheRoot options This is set to `{viteCacheDir}/swc` and override the default of `.swc`. ### Perf: simplify refresh wrapper generation ([#835](https://github.com/vitejs/vite-plugin-react/pull/835)) ## 4.0.1 (2025-08-19) ### Set `optimizeDeps.rollupOptions.transform.jsx` instead of `optimizeDeps.rollupOptions.jsx` for rolldown-vite ([#735](https://github.com/vitejs/vite-plugin-react/pull/735)) `optimizeDeps.rollupOptions.jsx` is going to be deprecated in favor of `optimizeDeps.rollupOptions.transform.jsx`. ## 4.0.0 (2025-08-07) ## 4.0.0-beta.0 (2025-07-28) ### Require Node 20.19+, 22.12+ This plugin now requires Node 20.19+ or 22.12+. ## 3.11.0 (2025-07-18) ### Add HMR support for compound components ([#518](https://github.com/vitejs/vite-plugin-react/pull/518)) HMR now works for compound components like this: ```tsx const Root = () =>
Accordion Root
const Item = () =>
Accordion Item
export const Accordion = { Root, Item } ``` ### Return `Plugin[]` instead of `PluginOption[]` ([#537](https://github.com/vitejs/vite-plugin-react/pull/537)) The return type has changed from `react(): PluginOption[]` to more specialized type `react(): Plugin[]`. This allows for type-safe manipulation of plugins, for example: ```tsx // previously this causes type errors react() .map(p => ({ ...p, applyToEnvironment: e => e.name === 'client' })) ``` ## 3.10.2 (2025-06-10) ### Suggest `@vitejs/plugin-react-oxc` if rolldown-vite is detected [#491](https://github.com/vitejs/vite-plugin-react/pull/491) Emit a log which recommends `@vitejs/plugin-react-oxc` when `rolldown-vite` is detected to improve performance and use Oxc under the hood. The warning can be disabled by setting `disableOxcRecommendation: true` in the plugin options. ### Use `optimizeDeps.rollupOptions` instead of `optimizeDeps.esbuildOptions` for rolldown-vite [#489](https://github.com/vitejs/vite-plugin-react/pull/489) This suppresses the warning about `optimizeDeps.esbuildOptions` being deprecated in rolldown-vite. ### Add Vite 7-beta to peerDependencies range [#497](https://github.com/vitejs/vite-plugin-react/pull/497) React plugins are compatible with Vite 7, this removes the warning when testing the beta. ## 3.10.1 (2025-06-03) ### Add explicit semicolon in preambleCode [#485](https://github.com/vitejs/vite-plugin-react/pull/485) This fixes an edge case when using HTML minifiers that strips line breaks aggressively. ## 3.10.0 (2025-05-23) ### Add `filter` for rolldown-vite [#470](https://github.com/vitejs/vite-plugin-react/pull/470) Added `filter` so that it is more performant when running this plugin with rolldown-powered version of Vite. ### Skip HMR preamble in Vitest browser mode [#478](https://github.com/vitejs/vite-plugin-react/pull/478) This was causing annoying `Sourcemap for "/@react-refresh" points to missing source files` and is unnecessary in test mode. ### Skip HMR for JSX files with hooks [#480](https://github.com/vitejs/vite-plugin-react/pull/480) This removes the HMR warning for hooks with JSX. ## 3.9.0 (2025-04-15) ### Make compatible with rolldown-vite This plugin is now compatible with rolldown-powered version of Vite. ## 3.9.0-beta.3 (2025-04-15) ### Add `reactRefreshHost` option Add `reactRefreshHost` option to set a React Fast Refresh runtime URL prefix. This is useful in a module federation context to enable HMR by specifying the host application URL in the Vite config of a remote application. See full discussion here: https://github.com/module-federation/vite/issues/183#issuecomment-2751825367 ```ts export default defineConfig({ plugins: [react({ reactRefreshHost: 'http://localhost:3000' })], }) ``` ## 3.9.0-beta.2 (2025-04-09) ## 3.9.0-beta.0 (2025-04-09) ## 3.8.1 ### Remove WebContainers warning [#268](https://github.com/vitejs/vite-plugin-react-swc/pull/268) SWC is now supported in WebContainers 🎉 ## 3.8.0 ### Add useAtYourOwnRisk_mutateSwcOptions option The future of Vite is with OXC, and from the beginning this was a design choice to not exposed too many specialties from SWC so that Vite React users can move to another transformer later. Also debugging why some specific version of decorators with some other unstable/legacy feature doesn't work is not fun, so we won't provide support for it, hence the name `useAtYourOwnRisk`. ```ts react({ useAtYourOwnRisk_mutateSwcOptions(options) { options.jsc.parser.decorators = true; options.jsc.transform.decoratorVersion = "2022-03"; }, }); ``` ## 3.7.2 ### Add Vite 6 to peerDependencies range [#207](https://github.com/vitejs/vite-plugin-react-swc/pull/207) Thanks @RobinTail ### Revert throw when refresh runtime is loaded twice [#237](https://github.com/vitejs/vite-plugin-react-swc/issues/237) Revert the throw when refresh runtime is loaded twice to enable usage in micro frontend apps. This was added to help fix setup usage, and this is not worth an annoying warning for others or a config parameter. This revert was done in the Babel plugin last year and I didn't port it back. ## 3.7.1 Ignore directive sourcemap error [#231](https://github.com/vitejs/vite-plugin-react-swc/issues/231) ## 3.7.0 ### Support HMR for class components This is a long overdue and should fix some issues people had with HMR when migrating from CRA. ## 3.6.0 ### Add parserConfig option This will unlock to use the plugin in some use cases where the original source code is not in TS. Using this option to keep using JSX inside `.js` files is highly discouraged and can be removed in any future version. ## 3.5.0 ### Update peer dependency range to target Vite 5 There were no breaking change that impacted this plugin, so any combination of React plugins and Vite core version will work. ### Align jsx runtime for optimized dependencies This will only affect people using internal libraries that contains untranspiled JSX. This change aligns the optimizer with the source code and avoid issues when the published source don't have `React` in the scope. Reminder: While being partially supported in Vite, publishing TS & JSX outside of internal libraries is highly discouraged. ## 3.4.1 ### Add support for `.mts` (fixes [#161](https://github.com/vitejs/vite-plugin-react-swc/issues/161)) Using CJS in source code will not work in Vite (and will never be supported), so this is better to only use `.ts`. But to better align with [Vite core defaults](https://vite.dev/config/shared-options.html#resolve-extensions), `.mts` extension will now be processed like `.ts`. This maybe reverted in a future major. ## 3.4.0 - Add `devTarget` option (fixes [#141](https://github.com/vitejs/vite-plugin-react-swc/issues/141)) - Disable Fast Refresh based on `config.server.hmr === false` instead of `process.env.TEST` - Warn when plugin is in WebContainers (see [#118](https://github.com/vitejs/vite-plugin-react-swc/issues/118)) - Better invalidation message when an export is added & fix HMR for export of nullish values ([#143](https://github.com/vitejs/vite-plugin-react-swc/issues/143)) ## 3.3.2 - Support [Vitest deps.experimentalOptimizer](https://vitest.dev/config/#deps-experimentaloptimizer) ([#115](https://github.com/vitejs/vite-plugin-react-swc/pull/115)) ## 3.3.1 - Add `type: module` to package.json ([#101](https://github.com/vitejs/vite-plugin-react-swc/pull/101)). Because the library already publish `.cjs` & `.mjs` files, the only change is for typing when using the node16 module resolution (fixes [#95](https://github.com/vitejs/vite-plugin-react-swc/issues/95)) - Throw an error when the MDX plugin is after this one ([#100](https://github.com/vitejs/vite-plugin-react-swc/pull/100)). This is an expected breaking change added in `3.2.0` and this should people that were using both plugins before this version to migrate. ## 3.3.0 - Support TS/JSX in node_modules to help the community experiment with it. Note that for now this not supported by TS and errors from these files cannot be silenced if the user is using a stricter configuration than the library author: https://github.com/microsoft/TypeScript/issues/30511. I advise to use it only for internal libraries for now (fixes #53) - Silence `"use client"` warning when building library like `@tanstack/react-query` - Fix fast refresh issue when exporting a component with a name that shadow another local component This release goes in hand with the upcoming Vite 4.3 release focusing on performances: - Move resolve of runtime code into a "pre" plugin ([#79](https://github.com/vitejs/vite-plugin-react-swc/pull/79)) - Wrap dynamic import to speedup analysis ([#80](https://github.com/vitejs/vite-plugin-react-swc/pull/80)) ## 3.2.0 - Support HMR for MDX (fixes #52) - Fix: when using plugins, apply SWC before esbuild so that automatic runtime is respected for JSX (fixes #56) - Fix: use jsxImportSource in optimizeDeps ## 3.1.0 - Support plugins via the new `plugins` options - Support TypeScript decorators via the new `tsDecorators` option. This requires `experimentalDecorators` in tsconfig. - Fix HMR for styled components exported alongside other components - Update embedded refresh runtime to 0.14 (fixes [#46](https://github.com/vitejs/vite-plugin-react-swc/issues/46)) ## 3.0.1 - Support Emotion via the new `jsxImportSource` option (fixes [#25](https://github.com/vitejs/vite-plugin-react-swc/issues/25)) To use it with Emotion, update your config to: ```ts export default defineConfig({ plugins: [react({ jsxImportSource: "@emotion/react" })], }); ``` - Fix HMR when using Vite `base` option (fixes [#18](https://github.com/vitejs/vite-plugin-react-swc/issues/18)) - Fix usage with workers (fixes [#23](https://github.com/vitejs/vite-plugin-react-swc/issues/23)) - Fix usage with `Vite Ruby` and `Laravel Vite` ([#20](https://github.com/vitejs/vite-plugin-react-swc/pull/20)) - Fix plugin default export when using commonjs (fixes [#14](https://github.com/vitejs/vite-plugin-react-swc/issues/14)) ## 3.0.0 This is plugin is now stable! 🎉 To migrate from `vite-plugin-swc-react-refresh`, see the `3.0.0-beta.0` changelog. ## 3.0.0-beta.2 - breaking: update plugin name to `vite:react-swc` to match official plugins naming - fix: don't add React Refresh wrapper for SSR transform (fixes [#11](https://github.com/vitejs/vite-plugin-react-swc/issues/11)) ## 3.0.0-beta.1 Fix package.json exports fields ## 3.0.0-beta.0 This is the first beta version of the official plugin for using [SWC](https://swc.rs/) with React in Vite! Some breaking changes have been made to make the plugin closer to the Babel one while keeping the smallest API surface possible to reduce bugs, encourage future-proof compilation output and allow easier opt-in into future perf improvements (caching, move to other native toolchain, ...): - Automatically enable automatic JSX runtime. "classic" runtime is not supported - Skip transformation for `.js` files - Enforce [useDefineForClassFields](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-7.html#the-usedefineforclassfields-flag-and-the-declare-property-modifier) - Don't pass `esbuild.define` config option to SWC. You can use the [top level define option](https://vite.dev/config/shared-options.html#define) instead - Use default export To migrate, change your config to: ```js import { defineConfig } from "vite"; import react from "@vitejs/plugin-react-swc"; export default defineConfig({ plugins: [react()], }); ``` This new release also include a runtime check for React refresh boundaries. When the conditions are not met (most of the time, exporting React components alongside functions or constant), the module is invalidated with a warning message to help you catch issues while keeping you page up-to date with code changes. ## 2.2.1 Skip react-refresh on SSR (Fixes [#2](https://github.com/vitejs/vite-plugin-react-swc/issues/2)) ## 2.2.0 - Always provide parser options to fix issue with `.jsx` imports. Relying on file extension for this is more buggy [than I though](https://github.com/swc-project/swc/issues/3297) - Extract line and column in SWC errors to make overlay filename clickable - Fix plugin name (`react-refresh` -> `swc-react-refresh`) ## 2.1.0 Add source maps support ## 2.0.3 Include `react/jsx-dev-runtime` for dependencies optimisation when using automatic runtime. ## 2.0.2 Unpinned `@swc/core` to get new features (like TS instantiation expression) despite a [30mb bump of bundle size](https://github.com/swc-project/swc/issues/3899) ## 2.0.1 Fix esbuild property in documentation. ## 2.0.0 Breaking: Use named export instead of default export for better esm/cjs interop. To migrate, replace your import by `import { swcReactRefresh } from "vite-plugin-swc-react-refresh";` The JSX automatic runtime is also now supported if you bump esbuild to at least [0.14.51](https://github.com/evanw/esbuild/releases/tag/v0.14.51). To use it, update your config from `esbuild: { jsxInject: 'import React from "react"' },` to `esbuild: { jsx: "automatic" },` ## 0.1.2 - Add vite as peer dependency - Pin @swc/core version to 1.2.141 to avoid a 30mb bump of bundle size ## 0.1.1 Add LICENSE ## 0.1.0 Initial release