vitejs / vite-plugin-react-swc

Speed up your Vite dev server with SWC
MIT License
770 stars 49 forks source link

React Compiler #205

Open samesfahani-tuplehealth opened 1 month ago

samesfahani-tuplehealth commented 1 month ago

Will there be instructions on how to use the new React Compiler given that it's babel based?

ArnaudBarre commented 1 month ago

For now the simplest way is to switch back to the Babel plugin. They working a Rust port, I hope this can be builtin in SWC in the future!

eeuneeun commented 1 month ago

how can I New React Compiler setting Vite project, now? I try to rewrite "vite.config.ts" file (plus plugins section) ..... but the "babel" letter makes errors

alireza-akbarzadeh commented 1 month ago

You should use vite-plugin-react

import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";

const ReactCompilerConfig = {};

export default defineConfig({
  plugins: [
    react({
      babel: {
        plugins: [["babel-plugin-react-compiler", ReactCompilerConfig]],
      },
    }),
  ],
});