-
Notifications
You must be signed in to change notification settings - Fork 46.8k
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
[compiler] Allow known React modules to be extended #31138
base: main
Are you sure you want to change the base?
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Thanks for the summary! We've been evolving compiler flags as we try to optimize for perf internally. One recently added option We haven't yet added support for defining react-like hooks (such as your re-exports) in
@josephsavona @mvitousek Thoughts on expanding |
Hmm, @tyxla can you share more context on why |
Thank you @mofeiZ and @josephsavona for the swift feedback!
This could potentially work for us, for what it's worth. From my perspective, React Compiler should have a way to understand if a module is a re-export of an original React module? After all, module aliases aren't unseen across the ecosystem.
Sure thing. Gutenberg is the block editor for WordPress, which runs on a major part of the web, and historically, we've wanted to keep it platform-independent, and let React be an abstraction under the hood, allowing 3rd party developers to work with a library of their choice. At the same time, full backward compatibility is one of our core values (we strive to minimize breaking changes), so we'll be obligated to maintain Let me know if that makes sense!
Worst case scenario, this might be something to consider after all, but I wanted to check if any alternatives are considered first. I appreciate if you have any further thoughts or vision to share. Thanks again! |
It's probably safer to start with the former and just allow type schemas to reference all of the builtin types. We can always expand to the former later, once we know what the set of attributes should be (I think we're about 90% confident of this right now but i'd rather defer canonicalizing this if possible) |
In the meantime, we're discussing the feasibility of using |
Summary
This PR suggests allowing the known React modules list to be extended.
Currently, in Gutenberg (The Block Editor project for WordPress) we expose (through re-exporting) React and React DOM APIs through the
@wordpress/element
package. In order for the React Compiler to treat the imports correctly, we need to be able to add@wordpress/element
to the list of known packages.The purpose is to expose this through a
knownReactModules
environment config property.How did you test this change?
I would still like to add some tests to verify this works as expected.