Skip to content

Conversation

@guoyunhe
Copy link
Contributor

@guoyunhe guoyunhe commented Nov 26, 2025

目前 antd 中有大量硬编码 /lib/ 的写法:

import dayjsGenerateConfig from '@rc-component/picker/lib/generate/dayjs';

虽然 antd 有编译时自动切换 /lib//es/ 的能力,但是写法不够优雅现代。

通过此 exports 映射之后,可以去掉硬编码 /lib/ /es/ 部分:

import dayjsGenerateConfig from '@rc-component/picker/generate/dayjs';

Summary by CodeRabbit

发布说明

  • Chores
    • 改进了包的导出配置,定义了多个公共入口点以增强模块化访问与按需加载
    • 增加了顶层 TypeScript 声明字段,完善了类型支持,提升开发者体验
    • 将 Node.js 最低版本要求从 8.x 提升至 12.x,以保证更好的兼容性与新特性支持

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

@vercel
Copy link

vercel bot commented Nov 26, 2025

@guoyunhe is attempting to deploy a commit to the React Component Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai
Copy link

coderabbitai bot commented Nov 26, 2025

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

修改 package.json 文件以完善包的导出配置。添加了顶级 types 字段指向类型定义文件,引入了详细的 exports 映射以定义多个公共入口点,并将 Node 引擎最小版本需求从 8.x 升级至 12.x。

Changes

Cohort / File(s) 变更摘要
包配置更新
package.json
添加顶级 types 字段(指向 es/index.d.ts);添加 exports 映射,定义 ../assets/*./generate./generate/*./interface./locale/* 等公共入口点,各入口均配置 typesimportrequire 解析;将 engines.node>=8.x 更新至 >=12.x

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

  • 需要确认 types 字段路径 es/index.d.ts 的正确性
  • 验证 exports 映射中所有入口点的实际文件结构是否对应
  • 确认最小 Node 版本升级至 12.x 不会影响现有用户的兼容性

Poem

🐰 包的出口焕然一新,
类型映射清晰分明,
Node 版本向前一步跨,
导出字段整齐排列,
公共接口井然有序。

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed 标题清晰准确地反映了 PR 的主要目标——添加 exports 字段支持,使消费者可以直接从子路径导入而无需硬编码 /lib/ 或 /es/ 路径。
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
🧪 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 47cca10 and 49ca3f0.

📒 Files selected for processing (1)
  • package.json (2 hunks)
⏰ 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). (2)
  • GitHub Check: Socket Security: Pull Request Alerts
  • GitHub Check: test / react component workflow
🔇 Additional comments (2)
package.json (2)

12-40: 导出配置已完善,之前的 assets 问题已解决。

对比之前的审查意见,此版本已正确地在 exports 中包含了 "./assets/*": "./assets/*"(第 19 行),确保了样式资源的可访问性,解决了之前的破坏性变更风险。

导出映射结构全面且合理:

  • 主入口点 (.)
  • Assets 文件通配符 (./assets/*)
  • 生成工具模块及其子路径 (./generate./generate/*)
  • 接口模块 (./interface)
  • 区域设置 (./locale/*)

所有导出都正确指定了 TypeScript 类型定义(指向 es 构建),并区分了 ESM 和 CommonJS 入口点。通配符模式在 Node 12.7.0+ 中得到支持,这与下文的引擎版本升级相符。


128-128: Node 引擎版本升级合理。

>=8.x 升级至 >=12.x 是必要的变更。Node 8 已于 2019 年底停止支持,而 exports 字段的完整支持(包括通配符模式)需要 Node 12.7.0+。此升级确保了新的 exports 配置能够正常工作。


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
Contributor

Summary of Changes

Hello @guoyunhe, 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!

此拉取请求在 package.json 中引入了 exports 字段,以实现模块解析的现代化。此更改旨在消除 antd 项目中导入路径中硬编码 /lib//es/ 的需要,从而实现更优雅和面向未来的模块导入。此外,它还更新了 Node.js 的最低版本要求,以符合更现代的开发环境标准。

Highlights

  • 支持 exports 字段: 在 package.json 中添加了 exports 字段,引入了现代模块解析机制,允许更简洁的导入路径,避免硬编码 /lib//es/
  • 更新 types 字段: 在 package.json 根级别添加了 types 字段,指向 ./es/index.d.ts,以更好地支持 TypeScript 类型解析。
  • Node.js 引擎要求更新: 将 package.jsonengines.node 的最低版本要求从 8.x 提升到 12.x
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.

Copy link
Contributor

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

Choose a reason for hiding this comment

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

Code Review

此次 PR 通过在 package.json 中添加 exports 字段,使得包的导入方式更加现代化,这是一个很好的改进。同时,升级了 node 引擎版本以支持 exports 特性。我的主要建议是,在 exports 字段中也需要导出 assets 目录下的样式文件,否则会导致用户无法导入样式文件,造成破坏性更新。

@codecov
Copy link

codecov bot commented Nov 26, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.80%. Comparing base (4e3723b) to head (49ca3f0).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #951   +/-   ##
=======================================
  Coverage   98.80%   98.80%           
=======================================
  Files          65       65           
  Lines        2680     2680           
  Branches      744      719   -25     
=======================================
  Hits         2648     2648           
  Misses         29       29           
  Partials        3        3           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@socket-security
Copy link

Warning

Review the following alerts detected in dependencies.

According to your organization's Security Policy, it is recommended to resolve "Warn" alerts. Learn more about Socket for GitHub.

Action Severity Alert  (click "▶" to expand/collapse)
Warn High
Obfuscated code: npm buffer-okam is 96.0% likely obfuscated

Confidence: 0.96

Location: Package overview

From: ?npm/buffer-okam@4.9.2

ℹ Read more on: This package | This alert | What is obfuscated code?

Next steps: Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at support@socket.dev.

Suggestion: Packages should not obfuscate their code. Consider not using packages with obfuscated code.

Mark the package as acceptable risk. To ignore this alert only in this pull request, reply with the comment @SocketSecurity ignore npm/buffer-okam@4.9.2. You can also ignore all packages with @SocketSecurity ignore-all. To ignore an alert for all future pull requests, use Socket's Dashboard to change the triage state of this alert.

Warn High
Obfuscated code: npm buffer is 96.0% likely obfuscated

Confidence: 0.96

Location: Package overview

From: ?npm/buffer@4.9.2

ℹ Read more on: This package | This alert | What is obfuscated code?

Next steps: Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at support@socket.dev.

Suggestion: Packages should not obfuscate their code. Consider not using packages with obfuscated code.

Mark the package as acceptable risk. To ignore this alert only in this pull request, reply with the comment @SocketSecurity ignore npm/buffer@4.9.2. You can also ignore all packages with @SocketSecurity ignore-all. To ignore an alert for all future pull requests, use Socket's Dashboard to change the triage state of this alert.

View full report

@zombieJ zombieJ merged commit ab0ffa0 into react-component:master Nov 26, 2025
7 of 8 checks passed
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