Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(cli): Add experimental setup command for React Compiler #10574

Merged
merged 6 commits into from
May 16, 2024

Conversation

Josh-Walker-GM
Copy link
Collaborator

@Josh-Walker-GM Josh-Walker-GM commented May 15, 2024

Problem
The react compiler has been discussed at the react conference and we should make it as easy as possible for people to try out in redwood. Especially since if you visit https://react.dev/learn/react-compiler you'll see specific mention of nextjs, remix and expo but not redwoodjs.

Changes

  1. Adds an experiment setup command which will add a flag to the redwood.toml, and install the react compiler eslint and babel plugin packages.
  2. Conditionally adds the eslint plugin & rule to our eslint config based on the toml flag
  3. Conditionally adds the babel plugin to our vite build process based on the toml flag.

Testing
I have only tested this on our standard test project fixture where you can see the compiler in action when you look via the react dev tools:
Screenshot 2024-05-15 at 21 42 11

Notes

  1. I decided to enforce that you are at least using react v19. Tobbe mentioned that in principle we could include polyfills to allow this to be used on earlier react versions, as per: Using the compiler on < React 19 reactwg/react-compiler#6. I don't love polyfilling things though but happy to defer that decision.

@Josh-Walker-GM Josh-Walker-GM added the release:feature This PR introduces a new feature label May 15, 2024
@Josh-Walker-GM Josh-Walker-GM added this to the next-release milestone May 15, 2024
@Josh-Walker-GM Josh-Walker-GM requested a review from Tobbe May 15, 2024 21:33
@Josh-Walker-GM Josh-Walker-GM self-assigned this May 15, 2024
@Josh-Walker-GM
Copy link
Collaborator Author

Josh-Walker-GM commented May 15, 2024

Note that the eslint plugin will not work until this fix has been published out to npm: facebook/react#29072.

Update: this fix has now been published and the setup command works as expected.

@Josh-Walker-GM Josh-Walker-GM enabled auto-merge (squash) May 16, 2024 12:35
@Josh-Walker-GM Josh-Walker-GM merged commit b76e3c7 into main May 16, 2024
46 checks passed
@Josh-Walker-GM Josh-Walker-GM deleted the jgmw/react-compiler-setup-command branch May 16, 2024 12:57
Josh-Walker-GM added a commit that referenced this pull request May 17, 2024
**Problem**
The react compiler has been discussed at the react conference and we
should make it as easy as possible for people to try out in redwood.
Especially since if you visit https://react.dev/learn/react-compiler
you'll see specific mention of nextjs, remix and expo but not redwoodjs.

**Changes**
1. Adds an experiment setup command which will add a flag to the
`redwood.toml`, and install the react compiler eslint and babel plugin
packages.
2. Conditionally adds the eslint plugin & rule to our eslint config
based on the toml flag
3. Conditionally adds the babel plugin to our vite build process based
on the toml flag.

**Testing**
I have only tested this on our standard test project fixture where you
can see the compiler in action when you look via the react dev tools:
<img width="1468" alt="Screenshot 2024-05-15 at 21 42 11"
src="https://github.com/redwoodjs/redwood/assets/56300765/e5113d1c-ba9f-48ca-9e4b-d0243758050a">
@Josh-Walker-GM Josh-Walker-GM modified the milestones: next-release, v7.6.0 May 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release:feature This PR introduces a new feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant