Skip to content

Releases: vitejs/vite-plugin-react-swc

v3.3.1

08 May 12:30
Compare
Choose a tag to compare
  • Add type: module to package.json (#101). Because the library already publish .cjs & .mjs files, the only change is for typing when using the node16 module resolution (fixes #95)
  • Throw an error when the MDX plugin is after this one (#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.

v3.3.0

09 Apr 01:53
Compare
Choose a tag to compare
  • 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: microsoft/TypeScript#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)
  • Wrap dynamic import to speedup analysis (#80)

v3.2.0

18 Feb 21:45
Compare
Choose a tag to compare
  • 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

v3.1.0

02 Feb 11:04
Compare
Choose a tag to compare
  • 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)

v3.1.0-beta.2

12 Jan 20:49
Compare
Choose a tag to compare
v3.1.0-beta.2 Pre-release
Pre-release
  • Fix HMR for styled components exported alongside other components
  • Support TypeScript decorators via the new tsDecorators option. This requires experimentalDecorators in tsconfig.
  • Support plugins via the new plugins options

v3.0.1

16 Dec 11:19
Compare
Choose a tag to compare
  • Support Emotion via the new jsxImportSource option (fixes #25)

To use it with Emotion, update your config to:

export default defineConfig({
  plugins: [react({ jsxImportSource: "@emotion/react" })],
});
  • Fix HMR when using Vite base option (fixes #18)
  • Fix usage with workers (fixes #23)
  • Fix usage with Vite Ruby and Laravel Vite (#20)
  • Fix plugin default export when using commonjs (fixes #14)

v3.0.0

09 Dec 10:07
Compare
Choose a tag to compare

This is plugin is now stable! πŸŽ‰

To migrate from vite-plugin-swc-react-refresh, see the 3.0.0-beta.0 changelog.

v3.0.0-beta.2

08 Dec 13:21
Compare
Choose a tag to compare
v3.0.0-beta.2 Pre-release
Pre-release
  • 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)

v3.0.0-beta.1

06 Dec 10:03
Compare
Choose a tag to compare
v3.0.0-beta.1 Pre-release
Pre-release

Fix package.json exports fields

v3.0.0-beta.0

05 Dec 10:33
Compare
Choose a tag to compare
v3.0.0-beta.0 Pre-release
Pre-release

This is the first beta version of the official plugin for using SWC 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
  • Don't pass esbuild.define config option to SWC. You can use the top level define option instead
  • Use default export

To migrate, change your config to:

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.