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

[compiler] Add support for canonical reactrc configs #31916

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft

Conversation

poteto
Copy link
Member

@poteto poteto commented Dec 26, 2024

This PR adds experimental support for a canoncial reactrc config file to be provided. This will be used later by other tooling such as a compiler upgrade script, IDE extension and so on, as the canonical configuration source for the compiler.

Stack created with Sapling. Best reviewed with ReviewStack.

Copy link

vercel bot commented Dec 26, 2024

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

Name Status Preview Comments Updated (UTC)
react-compiler-playground ❌ Failed (Inspect) Dec 27, 2024 9:39pm

Comment on lines +37 to +48
const reactConfig = findReactConfig();
let opts: PluginOptions | null = null;
if (reactConfig != null) {
opts = parsePluginOptions(reactConfig.config);
if (pass.opts != null) {
console.warn(
`Duplicate React Compiler config found, defaulting to reactrc found in: ${reactConfig.filepath}`,
);
}
} else {
opts = parsePluginOptions(pass.opts);
}
Copy link
Contributor

@mofeiZ mofeiZ Dec 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not very familiar with JS ecosystem convention, but doing multiple system calls per transformed file feels costly. Many tools (e.g. typescript, eslint) seem to find and read config files exactly once

Could we avoid this by reading configs on module load or caching the first result? The downside to this is that react-compiler projects would need to share a single config file (instead of being able to define per-directory overrides). If that doesn't sound ideal, could we maybe gate this feature behind a PluginOptions flag, e.g. disableReactRcFile.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point! This particular package caches parsed configs by default. I think we'll eventually want to add caching as well for the regular babel/zod parsed config

poteto added a commit that referenced this pull request Dec 27, 2024
There's no real reason to restrict the React peer dep to
non-experimental, so relax it.

---
[//]: # (BEGIN SAPLING FOOTER)
Stack created with [Sapling](https://sapling-scm.com). Best reviewed
with [ReviewStack](https://reviewstack.dev/facebook/react/pull/31915).
* #31919
* #31918
* #31917
* #31916
* __->__ #31915
* #31920
Update our various compiler rollup plugins.
This PR adds experimental support for a canoncial reactrc config file to be provided. This will be used later by other tooling such as a compiler upgrade script, IDE extension and so on, as the canonical configuration source for the compiler.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed React Core Team Opened by a member of the React Core Team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants