-
Notifications
You must be signed in to change notification settings - Fork 47.2k
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
base: main
Are you sure you want to change the base?
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
This was not committed in #31811 --- [//]: # (BEGIN SAPLING FOOTER) Stack created with [Sapling](https://sapling-scm.com). Best reviewed with [ReviewStack](https://reviewstack.dev/facebook/react/pull/31920). * #31919 * #31918 * #31917 * #31916 * #31915 * __->__ #31920
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); | ||
} |
There was a problem hiding this comment.
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
.
There was a problem hiding this comment.
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
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.
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.