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

chore(poc): react19 & compiler #20314

Draft
wants to merge 1 commit into
base: v5/main
Choose a base branch
from

Conversation

joshuaellis
Copy link
Member

What does it do?

This is POC to show off some of how react19 looks in Strapi and optionally, show the ability for us to use the react-compiler. You can enable the compiler by setting USE_REACT_COMPILER=true in your .env file! It's only set up for vite since we've deprecated webpack.

There's some bugs in how the design-system interacts with refs and the DOM which are being phased out in the DSv2 work anyway, so unfortunately something like the list-view in the CM doesn't work. Additionally, one big thing the compiler pointed out using npx react-compiler-healthcheck was:

Successfully compiled 625 out of 889 components.
StrictMode usage not found.
Found no usage of incompatible libraries.

Most of the components can be optimised! The main issue across the admin is our createContext function but we can fix this by probably removing it and implementing some guidelines on working with context in a similar way. The other biggest highlight was content-type-builder which has very poor health. Primarily down to the fact the data-fetching is all done in effects with refs (boo) this is something on our roadmap for a while though. Similarly, the app won't load with the plugins initialiser, but this can block the entire app from rendering so to be honest we should just get rid of it anyway and deprecate the methods in v5 lifecycle.

Overall, the transition doesn't look painful to use react@19, we should focus on the DS being easily compatible with the primary change of not needing to use forwardRef (woo) but we could do a v3 for the DS and upgrade the app at the same time. Hopefully when v2 is released we'll be able to use the entire CMS with react19 to test and play with 🥳

Notes

  • the lint will fail because i've added the eslint-plugin for react-compiler to error when something can't be optimised, very useful for insights, when we actively use the compiler, would just set it to warn.
  • I've got no hope in the test suite working at this point.

@joshuaellis joshuaellis added the flag: don't merge This PR should not be merged at the moment label May 16, 2024
@joshuaellis joshuaellis marked this pull request as draft May 16, 2024 08:19
@joshuaellis joshuaellis force-pushed the chore/react19-and-compiler-POC branch from 8d8fda0 to 8a6dabf Compare May 16, 2024 13:47
Copy link

vercel bot commented May 16, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
contributor-docs ❌ Failed (Inspect) May 16, 2024 1:49pm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
flag: don't merge This PR should not be merged at the moment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant