Skip to content

v3.0.0-beta.0

Pre-release
Pre-release
Compare
Choose a tag to compare
@ArnaudBarre ArnaudBarre released this 05 Dec 10:33
· 137 commits to main since this 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.