React Compiler Setup [Experimental]

React has announced its, currently experimental, React Compiler.

Try it out
You can now try this out in your redwood project by running:

yarn rw exp setup-react-compiler

After this you should be able to continue as you would normally using dev or build & serve. If you inspect your pages with the react dev tools you should hopefully see where the compiler has performed auto memoisation.

This command will install both the eslint and babel plugin packages. It will also enable a flag in your toml file:

  enabled = true

If you set enabled = false then this will disable the compiler integration.

This setup command is currently available in canary versions of redwood but will be released in our next stable release which is forthcoming.

Your project itself must:

  1. Your project is using Vite.
  2. Your project is using at least version 19 of React (currently in beta).
    • You will have this version if you have enabled the streaming-ssr or RSC experimental features.

This is an experimental feature from React and will not always work perfectly. You can tell us here but also please keep in mind that you might want to inform the React team as they will appreciate all feedback on their new product.

1 Like

Mostly works for my initial test (on a pretty basic app).

couple of caveats:

  1. i added dependencies to my package.json as suggest by react team
    @types/react”: “npm:types-react@beta”,
    @types/react-dom”: “npm:types-react-dom@beta”,

  2. As can be expected included packages might not work.
    in my case ‘react-to-print’ does not work (it does work in react 18.2.0

1 Like