Skip to content

feat: integrated react-compiler#290

Merged
zombieJ merged 8 commits into
ant-design:masterfrom
li-jia-nan:react-compiler
Nov 20, 2025
Merged

feat: integrated react-compiler#290
zombieJ merged 8 commits into
ant-design:masterfrom
li-jia-nan:react-compiler

Conversation

@li-jia-nan

@li-jia-nan li-jia-nan commented Nov 11, 2025

Copy link
Copy Markdown
Member

Summary by CodeRabbit

发布说明

  • 新功能

    • 添加 React 编译器支持选项,可通过配置启用以优化编译流程。
  • 杂项

    • 更新开发依赖,增强类型检查和编译支持。
    • 调整项目构建配置以适应新工具链。

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai

coderabbitai Bot commented Nov 11, 2025

Copy link
Copy Markdown

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

📝 Walkthrough

概述

该变更为项目添加了React编译器支持,包括新增TypeScript类型、更新构建配置以接受编译器选项,以及在BabelCommonConfig中实现条件化的React编译器插件注入。

变更清单

代码库 / 文件 变更摘要
配置文件和依赖
.gitignore, package.json
添加 pnpm-lock.yaml 到忽略列表;新增4个开发依赖(@types/babel__core@types/node@types/webpack-mergebabel-plugin-react-compiler)。
代码质量和格式
script/prettier.js, src/jest/demoPreprocessor.ts
移除catch块中未使用的错误变量;添加空行改进代码格式。
Babel配置核心
src/getBabelCommonConfig.ts
新增 BabelConfigOptionsBabelConfig 接口;扩展函数签名以接受options参数;实现条件化的React编译器插件注入(当 enabledReactCompiler 为true时);调整导入结构和导出方式。
Webpack集成
src/getWebpackConfig.ts
更新 GetWebpackConfigFunction 类型以接受optional options对象;将 enabledReactCompiler 选项传递给 getBabelCommonConfig;重构内部alias处理逻辑。
Gulp构建流程
src/gulpfile.ts
新增 ICompileStream 类型导入以增强类型安全;引入 LIB_DIR 环境变量支持;将库输出目录重命名为 cjsDir;基于编译目标条件性地启用React编译器选项。
Babel类型系统
src/jest/rewriteSource.ts
将分散的Babel类型导入统一为命名空间导入(import * as babel from '@babel/core');相应更新类型注解以使用命名空间前缀。

代码审查工作量评估

🎯 3 (中等复杂) | ⏱️ ~20 分钟

重点关注领域:

  • src/getBabelCommonConfig.ts: 新增接口定义和条件化插件注入逻辑需要验证React编译器目标版本和插件配置的正确性
  • src/gulpfile.ts: libDir/cjsDir的重命名和路径处理在多个位置需确认一致性,LIB_DIR环境变量的默认行为需要理解
  • 类型系统变更: 确保所有文件中的类型更新保持一致,特别是 getBabelCommonConfig 的返回类型变更是否正确传导到调用方

诗歌

🐰 哦,React编译器来临,
TypeScript守护我的代码行,
Babel配置更清晰,
选项流转穿三个地方,
类型安全护平安。 ✨

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed PR标题准确总结了主要变更:集成React编译器,涵盖了新增依赖、配置修改和多个源文件的功能调整。
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e2d96dd and 6459a73.

📒 Files selected for processing (2)
  • package.json (1 hunks)
  • src/jest/demoPreprocessor.ts (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • src/jest/demoPreprocessor.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • package.json
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Socket Security: Pull Request Alerts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @li-jia-nan, 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 the React Compiler into the project's build pipeline. The primary goal is to leverage automatic memoization and optimization capabilities provided by the compiler to enhance the performance of React applications. This involves updating project dependencies, configuring Babel to use the new plugin, and making minor adjustments to development-related files.

Highlights

  • React Compiler Integration: The babel-plugin-react-compiler has been integrated into the project's Babel configuration, specifically targeting React 18 for automatic optimization of React components.
  • Dependency Updates: New development dependencies, including @types/babel__core, @types/node, and babel-plugin-react-compiler, have been added to package.json to support the new compiler setup.
  • Build Configuration Adjustments: The .gitignore file has been updated to include pnpm-lock.yaml, and a minor change was made in script/prettier.js to simplify error catching.
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.

@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 integrates the React Compiler by adding the babel-plugin-react-compiler and its necessary dependencies. The Babel configuration is updated to include the new plugin. The changes are generally good, but I have a couple of suggestions for src/getBabelCommonConfig.ts to improve consistency and maintainability: one regarding module resolution for the new plugin and another about a comment's language. Additionally, some minor code quality improvements are included in other files.

Comment thread src/getBabelCommonConfig.ts Outdated
Comment thread src/getBabelCommonConfig.ts Outdated
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9dcecb4 and d14b847.

📒 Files selected for processing (4)
  • .gitignore (1 hunks)
  • package.json (1 hunks)
  • script/prettier.js (1 hunks)
  • src/getBabelCommonConfig.ts (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
script/prettier.js (1)
script/lint-prettier.js (1)
  • didError (16-16)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Socket Security: Pull Request Alerts
🔇 Additional comments (5)
.gitignore (1)

28-28: LGTM!

添加 pnpm-lock.yaml 到 .gitignore 是合理的做法,与 PR 中的工具链更新保持一致。

script/prettier.js (1)

40-42: LGTM!

移除未使用的错误变量是合理的简化。现代 JavaScript 支持不绑定错误参数的 catch 语句。

src/getBabelCommonConfig.ts (3)

5-7: LGTM!

添加 BabelConfig 接口继承 TransformOptions 并扩展 cacheDirectory 字段是合理的类型定义,提高了类型安全性。


9-9: LGTM!

函数返回类型更新为 BabelConfig 接口,与新定义的接口保持一致,提供了更好的类型检查。


11-16: 检查 React Compiler 配置:已验证,发现需改进的地方。

根据官方 React Compiler 文档确认,target 选项接受字符串值 '17'、'18' 或 '19',目前使用的 '18' 格式正确。

已验证的项目:

  1. target 配置格式 ✓:字符串格式 '18' 符合官方规范
  2. 插件顺序 ✓:React Compiler 正确地被放置在插件数组第一位,@babel/plugin-transform-typescript 在第二位,执行顺序符合官方要求
  3. 兼容性 ✓:与 @babel/preset-react ^7.0.0 和其他 Babel 插件兼容

需要改进的地方:

根据官方文档,当目标版本低于 React 19(即 '17' 或 '18')时,应将 react-compiler-runtime 添加为依赖。当前项目的 package.json 中缺少此依赖。请确认是否需要将 react-compiler-runtime 添加到项目依赖中。

Comment thread package.json
Comment thread src/getBabelCommonConfig.ts

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

♻️ Duplicate comments (1)
src/getBabelCommonConfig.ts (1)

36-43: 建议将代码注释改为英文。

根据之前的审查意见,为了保持项目一致性并方便国际贡献者,建议将第 40 行的中文注释改为英文。

建议应用以下修改:

       {
-        target: '18', // 最低支持的版本是 React 18
+        target: '18', // The minimum supported version is React 18
       },

相关审查意见:之前的评审中已经指出需要使用英文注释。

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 487a4aa and 242fb70.

📒 Files selected for processing (6)
  • src/getBabelCommonConfig.ts (3 hunks)
  • src/getWebpackConfig.ts (1 hunks)
  • src/gulpfile.ts (2 hunks)
  • src/jest/codePreprocessor.ts (1 hunks)
  • src/jest/demoPreprocessor.ts (1 hunks)
  • src/jest/rewriteSource.ts (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (3)
src/jest/rewriteSource.ts (2)
src/jest/codePreprocessor.ts (1)
  • ImportDeclaration (13-15)
src/jest/demoPreprocessor.ts (1)
  • ImportDeclaration (93-102)
src/getWebpackConfig.ts (2)
src/jest/codePreprocessor.ts (1)
  • process (37-70)
src/utils/projectHelper.ts (1)
  • getProjectPath (6-8)
src/getBabelCommonConfig.ts (1)
src/utils/projectHelper.ts (1)
  • resolve (10-12)
🔇 Additional comments (7)
src/getWebpackConfig.ts (1)

38-45: 实现正确,逻辑清晰。

新增的 libDir 常量和对 getBabelCommonConfig 的调用符合预期。仅在 libDir === 'dist' 时启用 React Compiler,这样的条件判断合理且与其他文件保持一致。

src/jest/demoPreprocessor.ts (1)

123-125: 实现正确。

正确地将 enabledReactCompiler 选项传递给 getBabelCommonConfig,与其他文件的实现保持一致。

src/jest/codePreprocessor.ts (1)

39-41: 实现正确。

正确地将 enabledReactCompiler 选项传递给 getBabelCommonConfig,与其他文件的实现保持一致。

src/jest/rewriteSource.ts (1)

1-5: 类型改进合理。

统一了 Babel 类型的导入方式,类型注解更加明确,运行时行为保持不变。

src/getBabelCommonConfig.ts (3)

5-11: 类型定义清晰合理。

新增的 BabelConfigOptionsBabelConfig 接口设计良好,为配置提供了类型安全保障。


13-14: 函数签名改进提升了可配置性。

新增的 options 参数使得 Babel 配置更加灵活,PluginItem[] 类型注解也增强了类型安全。


63-63: 正确导出函数。

新增的默认导出语句使得该函数可以被其他模块正确引用。

Comment thread src/gulpfile.ts Outdated
@li-jia-nan li-jia-nan requested a review from zombieJ November 13, 2025 01:43
Comment thread src/getWebpackConfig.ts Outdated
@socket-security

socket-security Bot commented Nov 20, 2025

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Added@​types/​webpack-merge@​5.0.0981003977100
Addedbabel-plugin-react-compiler@​1.0.01001007997100

View full report

@zombieJ zombieJ merged commit 7e8821e into ant-design:master Nov 20, 2025
5 checks passed
@li-jia-nan li-jia-nan deleted the react-compiler branch June 18, 2026 02:43
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