Skip to content

feat(pack): support config.react - #2592

Merged
fireairforce merged 2 commits into
nextfrom
support-jsx-runtime
Feb 11, 2026
Merged

feat(pack): support config.react#2592
fireairforce merged 2 commits into
nextfrom
support-jsx-runtime

Conversation

@fireairforce

@fireairforce fireairforce commented Feb 11, 2026

Copy link
Copy Markdown
Member

Summary

closes: #2590

copy mako: https://makojs.dev/docs/config#react

Test Plan

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @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 react configuration option, providing granular control over the JSX runtime mode within the application's build process. This enhancement allows for explicit definition of whether JSX transformations should use the 'automatic' or 'classic' runtime, improving flexibility and resolving previous issues related to JSX pragma conflicts. The changes ensure that the specified JSX runtime is consistently applied across different code contexts, leading to more predictable and configurable JSX compilation.

Highlights

  • New Configuration Option: Introduced a new react configuration option within the Config struct, allowing users to specify the JSX runtime mode (e.g., "automatic" or "classic").
  • JSX Runtime Control: The get_jsx_transform_options function now utilizes the newly added config.react setting to determine the JSX runtime, defaulting to "automatic" if not explicitly set.
  • Contextual JSX Application: Updated the client module options context to correctly apply JSX transform options to both foreign and internal code contexts, ensuring consistent behavior across different module types.
  • Test Case Update: Modified a snapshot test case (foreign_jsx_transform) to include the new react.runtime: "classic" configuration, and removed an associated error file, indicating a resolution to a previous JSX-related issue.
Changelog
  • crates/pack-core/src/client/context.rs
    • Renamed jsx_runtime_options to jsx_transform_options for improved clarity.
    • Removed a redundant default enable_jsx initialization.
    • Applied jsx_transform_options to foreign_codes_options_context and internal_context.
  • crates/pack-core/src/config.rs
    • Added react: Option<ReactConfig> field to the main Config struct.
    • Introduced a new ReactConfig struct to encapsulate JSX runtime settings.
    • Implemented a react() getter function within Config to access the ReactConfig.
  • crates/pack-core/src/transform_options.rs
    • Removed outdated comments regarding Next.js JSX runtime overrides.
    • Integrated the config.react() value to dynamically set the JSX runtime, with a default of "automatic".
  • crates/pack-tests/tests/snapshot/basic/foreign_jsx_transform/config.json
    • Updated the test configuration to include react.runtime: "classic".
  • crates/pack-tests/tests/snapshot/basic/foreign_jsx_transform/issues/Ecmascript-file-had-an-error-df4108.txt
    • Removed an error snapshot file, indicating the resolution of a previous issue.
Activity
  • The pull request was created by fireairforce.
  • The PR description indicates that it closes issue https://github.com/utooland/utoo/pull/2590.
Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@fireairforce
fireairforce merged commit 68d2b1f into next Feb 11, 2026
16 checks passed
@fireairforce
fireairforce deleted the support-jsx-runtime branch February 11, 2026 19:02

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

Comment on lines +244 to +250
#[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>,
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

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())),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

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.

Suggested change
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())),

@github-actions

Copy link
Copy Markdown

📊 Performance Benchmark Report (with-antd)

Utoopack Performance Report

Report ID: utoopack_performance_report_20260211_192133
Generated: 2026-02-11 19:21:33
Trace File: trace_antd.json (0.5GB, 3.18M events)
Test Project: examples/with-antd


Executive Summary

Key Findings

Metric Value Assessment
Total Wall Time 7,714.8 ms Baseline
Total Thread Work (de-duped) 24,489.2 ms Non-overlapping busy time
Effective Parallelism 3.2x thread_work / wall_time
Working Threads 5 Threads with actual spans
Thread Utilization 63.5% 🆗 Average
Total Spans 1,590,233 All B/E + X events
Meaningful Spans (>= 10us) 492,361 (31.0% of total)
Tracing Noise (< 10us) 1,097,872 (69.0% of total)

Note on Thread Work: Thread work is computed by merging overlapping intervals
per thread, eliminating double-counting from nested spans. This gives the true
wall-clock busy time across all threads.

Workload Distribution by Tier

Category Tasks Total Time (ms) % of Thread Work
P0: Runtime/Resolution 0 0.0 0.0%
P1: I/O & Heavy Tasks 37,493 3,483.4 14.2%
P3: Asset Pipeline 28,331 3,389.3 13.8%
P4: Bridge/Interop 0 0.0 0.0%
Other 426,537 20,399.6 83.3%

Note: Percentages may sum to >100% because task durations include nesting
while thread work is de-duplicated. This is intentional for hotspot attribution.


Parallelization Analysis

Thread Utilization

Metric Value
Working Threads 5
Total Thread Work (de-duped) 24,489.2 ms
Avg Work per Thread 4,897.8 ms
Effective Parallelism 3.17x
Thread Utilization 63.5%

Assessment: With 5 working threads, achieving 3.2x parallelism indicates significant loss of potential parallelism.


Top 20 Tasks by Total Duration

Total (ms) Count Avg (us) Max (ms) % Work Task Name
7,690.7 176,433 43.6 9.9 31.4% module
3,982.6 66,888 59.5 201.2 16.3% process module
3,418.6 34,616 98.8 201.1 14.0% analyze ecmascript module
2,648.2 23,974 110.5 82.6 10.8% code generation
1,657.7 55,667 29.8 11.1 6.8% resolving
1,652.5 59,929 27.6 9.4 6.7% internal resolving
1,609.4 13,666 117.8 127.6 6.6% chunking
1,263.4 27,832 45.4 13.2 5.2% precompute code generation
1,199.4 12,767 93.9 115.9 4.9% compute async module info
944.1 8,042 117.4 38.0 3.9% parse ecmascript
472.3 4,584 103.0 42.8 1.9% compute async chunks
287.2 1,936 148.4 16.8 1.2% generate source map
70.6 1,858 38.0 13.9 0.3% collect mergeable modules
63.2 576 109.7 15.3 0.3% compute binding usage info
61.5 97 634.1 19.6 0.3% make production chunks
56.0 2,165 25.9 0.3 0.2% read file
35.4 4 8853.8 19.6 0.1% compute merged modules
31.0 14 2212.5 11.9 0.1% apply effects
30.3 13 2333.1 11.7 0.1% write file
24.1 545 44.1 2.8 0.1% async reference

Deep Dive by Tier

Tier 1: Runtime & Resolution (P0)

Focus: Task scheduling and dependency resolution.

Metric Value Status
Total Scheduling Time 0.0 ms ✅ Normal
Resolution Hotspots 0 distinct task types Check Top Tasks

Potential P0 Issues:

  • Thread utilization at 63.5% suggests critical path serialization or lock contention.
  • 1,097,872 spans < 10us (69.0%) contribute to scheduler pressure.

Tier 2: Physical & Resource Barriers (P1)

Focus: Hardware utilization, I/O, and heavy monoliths.

Metric Value Status
I/O Work (Estimated) 3,483.4 ms ✅ Healthy
Large Tasks (> 100ms) 4 Minimal

Tier 3: Architecture & Asset Pipeline (P2-P3)

Focus: Global state and transformation pipeline.

Metric Value Status
Asset Processing (P3) 3,389.3 ms 13.8% of work
Bridge Overhead (P4) 0.0 ms ✅ Low

Duration Distribution

Range Count Percentage
< 10us (noise) 1,097,872 69.0%
10us - 100us 468,496 29.5%
100us - 1ms 20,034 1.3%
1ms - 10ms 3,744 0.2%
10ms - 100ms 83 0.0%
> 100ms 4 0.0%

Diagnostic Signal Summary

Signal Status Finding
Tracing Noise (P0) ⚠️ Significant 69.0% of spans < 10us
Thread Utilization (P0) 🆗 Average 63.5% utilization
Heavy Monoliths (P1) ✅ Minimal 4 tasks > 100ms
Asset Pipeline (P3) Review 3,389.3 ms total
Bridge/Interop (P4) Low 0.0 ms total

Action Items (P0-P4)

  1. [P0] Profile lock contention to address 36% lost parallelism
  2. [P1] Breakdown heavy monolith tasks (>100ms) to improve granularity
  3. [P1] Review I/O patterns for potential batching opportunities
  4. [P3] Optimize asset transformation pipeline hot-spots
  5. [P4] Reduce "chatty" bridge operations if interop overhead is significant

Report generated by Utoopack Performance Analysis Agent on 2026-02-11
Following: Utoopack Performance Analysis Agent Protocol

@xusd320

xusd320 commented Feb 12, 2026

Copy link
Copy Markdown
Contributor

ts 类型也没加啊?

#[serde(rename_all = "camelCase")]
pub struct ReactConfig {
/// JSX runtime mode: "automatic" (default) or "classic"
pub runtime: Option<RcStr>,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

enum !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants