vite-plugin-react icon indicating copy to clipboard operation
vite-plugin-react copied to clipboard

React Compiler with plugin-swc

Open samesfahani-tuplehealth opened this issue 1 year ago • 8 comments

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

samesfahani-tuplehealth avatar May 16 '24 00:05 samesfahani-tuplehealth

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!

ArnaudBarre avatar May 16 '24 09:05 ArnaudBarre

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

eeuneeun avatar May 27 '24 05:05 eeuneeun

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]],
      },
    }),
  ],
});

alireza-akbarzadeh avatar May 29 '24 05:05 alireza-akbarzadeh

Will be there an option to use react compiler with SWC in the future?

matej-kaska avatar Oct 31 '24 10:10 matej-kaska

If the React team lands the Rust port of the compiler, I think SWC will try to integrate it directly. But the rust part didn't get updated since annouced: https://github.com/facebook/react/commits/main/compiler/crates

ArnaudBarre avatar Nov 01 '24 19:11 ArnaudBarre

The Rust port has been removed: https://github.com/facebook/react/pull/32219

For React Compiler though, we plan to continue using JavaScript and explore lightweight native wrappers for things like OXC and SWC plugins.

AaronDewes avatar Jan 28 '25 11:01 AaronDewes

Yeah, they still plan to have some integrations, but it will probably take times too

ArnaudBarre avatar Jan 31 '25 16:01 ArnaudBarre

See also https://github.com/oxc-project/oxc/issues/10048

rakleed avatar May 23 '25 10:05 rakleed

Any update on this please?

Hanaffi avatar Nov 24 '25 21:11 Hanaffi