feat(pack): support config.react - #2592
Conversation
Summary of ChangesHello @fireairforce, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request introduces a new Highlights
Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request introduces support for configuring the React JSX runtime via a new config.react.runtime option. The changes are well-implemented, adding the necessary configuration structs and plumbing the option down to the JSX transform options. The test cases are also updated to reflect this new feature.
I have a couple of suggestions to improve the implementation by using an enum for the runtime option. This will enhance type safety and provide better validation for user-provided configurations.
| #[turbo_tasks::value(eq = "manual")] | ||
| #[derive(Clone, Debug, PartialEq, Default, Deserialize, OperationValue)] | ||
| #[serde(rename_all = "camelCase")] | ||
| pub struct ReactConfig { | ||
| /// JSX runtime mode: "automatic" (default) or "classic" | ||
| pub runtime: Option<RcStr>, | ||
| } |
There was a problem hiding this comment.
For better type safety and to provide validation for the runtime option, it's recommended to use an enum instead of a raw RcStr. This will ensure that only valid values ("automatic" or "classic") are accepted, providing better error messages to the user for invalid configurations at deserialization time.
You can define a JsxRuntime enum and use it in ReactConfig.
#[turbo_tasks::value]
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, OperationValue)]
#[serde(rename_all = "camelCase")]
pub enum JsxRuntime {
Automatic,
Classic,
}
impl JsxRuntime {
pub fn as_str(&self) -> &'static str {
match self {
JsxRuntime::Automatic => "automatic",
JsxRuntime::Classic => "classic",
}
}
}
#[turbo_tasks::value(eq = "manual")]
#[derive(Clone, Debug, PartialEq, Default, Deserialize, OperationValue)]
#[serde(rename_all = "camelCase")]
pub struct ReactConfig {
/// JSX runtime mode: "automatic" (default) or "classic"
pub runtime: Option<JsxRuntime>,
}| None | ||
| }, | ||
| runtime: Some("automatic".into()), | ||
| runtime: react_config.runtime.clone().or(Some("automatic".into())), |
There was a problem hiding this comment.
To align with the suggested change of using an enum for runtime in ReactConfig, this line should be updated to handle the enum type. This involves mapping the enum variant to its string representation.
| runtime: react_config.runtime.clone().or(Some("automatic".into())), | |
| runtime: react_config.runtime.as_ref().map(|r| r.as_str().into()).or(Some("automatic".into())), |
📊 Performance Benchmark Report (with-antd)Utoopack Performance ReportReport ID: Executive SummaryKey Findings
Workload Distribution by Tier
Parallelization AnalysisThread Utilization
Assessment: With 5 working threads, achieving 3.2x parallelism indicates significant loss of potential parallelism. Top 20 Tasks by Total Duration
Deep Dive by TierTier 1: Runtime & Resolution (P0)Focus: Task scheduling and dependency resolution.
Potential P0 Issues:
Tier 2: Physical & Resource Barriers (P1)Focus: Hardware utilization, I/O, and heavy monoliths.
Tier 3: Architecture & Asset Pipeline (P2-P3)Focus: Global state and transformation pipeline.
Duration Distribution
Diagnostic Signal Summary
Action Items (P0-P4)
Report generated by Utoopack Performance Analysis Agent on 2026-02-11 |
|
ts 类型也没加啊? |
| #[serde(rename_all = "camelCase")] | ||
| pub struct ReactConfig { | ||
| /// JSX runtime mode: "automatic" (default) or "classic" | ||
| pub runtime: Option<RcStr>, |
Summary
closes: #2590
copy mako: https://makojs.dev/docs/config#react
Test Plan