vite-plugin-react-swc

Speed up your Vite dev server with SWC

MIT License

Downloads
5.2M
Stars
732
Committers
8

Bot releases are visible (Hide)

vite-plugin-react-swc - v3.6.0 Latest Release

Published by github-actions[bot] 9 months ago

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.

vite-plugin-react-swc - v3.5.0

Published by github-actions[bot] 11 months ago

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.

vite-plugin-react-swc - v3.4.1

Published by github-actions[bot] 12 months ago

Add support for .mts (fixes #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, .mts extension will now be processed like .ts. This maybe reverted in a future major.

vite-plugin-react-swc - v3.4.0

Published by github-actions[bot] about 1 year ago

  • Add devTarget option (fixes #141)
  • Disable Fast Refresh based on config.server.hmr === false instead of process.env.TEST
  • Warn when plugin is in WebContainers (see #118)
  • Better invalidation message when an export is added & fix HMR for export of nullish values (#143)
vite-plugin-react-swc - v3.3.2

Published by ArnaudBarre over 1 year ago

vite-plugin-react-swc - v3.3.1

Published by ArnaudBarre over 1 year ago

  • 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.
vite-plugin-react-swc - v3.3.0

Published by github-actions[bot] over 1 year ago

  • 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)
  • Wrap dynamic import to speedup analysis (#80)
vite-plugin-react-swc - v3.2.0

Published by github-actions[bot] over 1 year ago

  • 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
vite-plugin-react-swc - v3.1.0

Published by github-actions[bot] over 1 year ago

  • 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)
vite-plugin-react-swc - v3.1.0-beta.2

Published by github-actions[bot] almost 2 years ago

  • 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
vite-plugin-react-swc - v3.0.1

Published by ArnaudBarre almost 2 years ago

  • 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)
vite-plugin-react-swc - v3.0.0

Published by ArnaudBarre almost 2 years ago

This is plugin is now stable! πŸŽ‰

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

vite-plugin-react-swc - v3.0.0-beta.2

Published by ArnaudBarre almost 2 years ago

  • 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)
vite-plugin-react-swc - v3.0.0-beta.1

Published by ArnaudBarre almost 2 years ago

Fix package.json exports fields

vite-plugin-react-swc - v3.0.0-beta.0

Published by ArnaudBarre almost 2 years ago

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.

vite-plugin-react-swc - v2.2.1

Published by github-actions[bot] almost 2 years ago

Skip react-refresh on SSR (Fixes #2)

vite-plugin-react-swc - v2.2.0

Published by github-actions[bot] almost 2 years ago

  • Always provide parser options to fix issue with .jsx imports. Relying on file extension for this is more buggy than I though
  • Extract line and column in SWC errors to make overlay filename clickable
  • Fix plugin name (react-refresh -> swc-react-refresh)
vite-plugin-react-swc - v2.1.0

Published by github-actions[bot] almost 2 years ago

Add source maps support

vite-plugin-react-swc - v2.0.3

Published by github-actions[bot] about 2 years ago

Include react/jsx-dev-runtime for dependencies optimisation when using automatic runtime.

vite-plugin-react-swc - v2.0.2

Published by github-actions[bot] about 2 years ago

Unpinned @swc/core to get new features (like TS instantiation expression) despite a 30mb bump of bundle size