Skip to content

Avoid rc package deep imports#1223

Open
QDyanbing wants to merge 1 commit into
react-component:masterfrom
QDyanbing:avoid-deep-imports
Open

Avoid rc package deep imports#1223
QDyanbing wants to merge 1 commit into
react-component:masterfrom
QDyanbing:avoid-deep-imports

Conversation

@QDyanbing
Copy link
Copy Markdown
Contributor

@QDyanbing QDyanbing commented May 22, 2026

背景

避免 rc 包之间继续依赖 es / lib 构建产物路径,统一改为从包根入口导入公开 API。

调整内容

  • 升级 @rc-component/father-plugin,交由插件统一限制深路径导入。
  • 升级 @rc-component/util@rc-component/virtual-list,使用根入口已导出的 API。
  • 将当前包内对其他 rc 包 lib 路径的导入替换为包根入口导入。
  • 补充 @rc-component/select 根入口类型导出,方便下游包和 antd 去除深路径导入。
  • 移除不再需要的临时 typings 声明。

验证

  • npm run lint 通过,仅存在项目已有 warning。

Summary by CodeRabbit

发布说明

  • Chores

    • 更新依赖版本:@rc-component/util 升级至 v1.11.1,@rc-component/virtual-list 升级至 v1.2.0,@rc-component/father-plugin 升级至 v2.2.0
  • Refactor

    • 优化模块导入结构,简化依赖引入方式
  • 其他

    • 扩展公开类型导出,提供更全面的类型支持

Review Change Stack

@vercel
Copy link
Copy Markdown

vercel Bot commented May 22, 2026

@QDyanbing 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
Copy Markdown
Contributor

coderabbitai Bot commented May 22, 2026

变更总览

本次 PR 将 @rc-component/select 库的依赖版本升级至最新,并统一调整所有源文件、测试文件和类型声明中对 @rc-component/util@rc-component/virtual-list@rc-component/trigger 的导入,从内部 lib/... 子路径改为从包的顶层入口点导入,同时扩展了公开 API 的类型导出。

变更详情

导入路径迁移与 API 扩展

层级 / 文件 摘要
依赖版本升级
package.json
@rc-component/util 升级至 ^1.11.1@rc-component/virtual-list 升级至 ^1.2.0@rc-component/father-plugin 升级至 ^2.2.0
核心组件导入统一
src/BaseSelect/index.tsx, src/Select.tsx, src/SelectTrigger.tsx, src/OptionList.tsx
BaseSelect 从包顶层导入 AlignTypeBuildInPlacementsgetDOMuseEventScrollConfig 等;Select 从包顶层导入 useControlledStateuseIdwarning;SelectTrigger 从包顶层导入触发器相关类型;OptionList 从包顶层导入工具函数及虚拟列表相关类型。
SelectInput 导入更新
src/SelectInput/index.tsx, src/SelectInput/Content/index.tsx, src/SelectInput/Input.tsx
pickAttrscomposeRefuseLayoutEffectKeyCodegetDOMuseEvent 等工具从包顶层统一导入。
工具函数导入调整
src/utils/keyUtil.ts, src/utils/legacyUtil.ts, src/utils/valueUtil.ts, src/utils/warningPropsUtil.ts
KeyCodetoArraywarningnoteOnce 等工具函数的导入从子路径改为从包顶层的命名导入。
公开 API 类型导出扩展
src/index.ts
扩展 export type 列表,新增导出 BaseSelectSemanticNameDisplayValueTypeRefOptionListPropsOptionFCOptionPropsPlacement 等 10+ 个公开类型,并调整导入源为分离的类型导入语句。
测试文件导入统一
tests/*.test.tsx, tests/shared/*.tsx
在 9 个测试文件中统一调整 KeyCoderesetWarnedspyElementPrototypesScrollConfig 的导入源为主包入口。
TypeScript 声明清理
typings/index.d.ts
删除 @rc-component/util/lib/Children/toArray 的无效模块声明。

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

相关 PR

建议的审阅者

  • zombieJ
  • Wxh16144

🐰 版本升级路径通畅,
子路径归一好轻松,
工具统一齐导入,
公开 API 更宽阔,
测试全覆盖检验,
类型声明整洁通!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed 标题准确总结了主要变更内容:避免从rc包的深层路径导入,改为使用包根API。
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

src/BaseSelect/index.tsx

ESLint skipped: missing config or dependency (missing-dependency). The ESLint configuration references a package that is not available in the sandbox.

src/OptionList.tsx

ESLint skipped: the ESLint configuration for this file references a package that is not available in the sandbox.

src/Select.tsx

ESLint skipped: the ESLint configuration for this file references a package that is not available in the sandbox.

  • 18 others

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.

@codecov
Copy link
Copy Markdown

codecov Bot commented May 22, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.44%. Comparing base (6fe40e3) to head (627fa3b).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1223   +/-   ##
=======================================
  Coverage   99.44%   99.44%           
=======================================
  Files          31       31           
  Lines        1266     1266           
  Branches      442      442           
=======================================
  Hits         1259     1259           
  Misses          7        7           

☔ 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.

Copy link
Copy Markdown
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

This pull request updates the versions of @rc-component/util and @rc-component/virtual-list and refactors imports across the codebase to use root package paths instead of deep internal paths. It also expands the types exported from the main entry point. The reviewer recommends exporting additional common types, such as RawValueType and Mode, to better support downstream consumers and further eliminate the need for deep imports.

Comment thread src/index.ts
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@tests/shared/throwOptionValue.tsx`:
- Line 3: The import of resetWarned is incorrect — it is not exported from the
top-level '`@rc-component/util`'; update the import statement that currently reads
"import { resetWarned } from '`@rc-component/util`';" to import from the warning
submodule instead, e.g. "import { resetWarned } from
'`@rc-component/util/lib/warning`';" so the resetWarned symbol is resolved from
the correct module.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: d1ee11b6-66e0-4e5b-bfb9-a7e55fc9f025

📥 Commits

Reviewing files that changed from the base of the PR and between 6fe40e3 and 627fa3b.

📒 Files selected for processing (23)
  • package.json
  • src/BaseSelect/index.tsx
  • src/OptionList.tsx
  • src/Select.tsx
  • src/SelectInput/Content/index.tsx
  • src/SelectInput/Input.tsx
  • src/SelectInput/index.tsx
  • src/SelectTrigger.tsx
  • src/index.ts
  • src/utils/keyUtil.ts
  • src/utils/legacyUtil.ts
  • src/utils/valueUtil.ts
  • src/utils/warningPropsUtil.ts
  • tests/Accessibility.test.tsx
  • tests/Combobox.test.tsx
  • tests/Multiple.test.tsx
  • tests/OptionList.test.tsx
  • tests/Select.test.tsx
  • tests/Tags.test.tsx
  • tests/shared/focusTest.tsx
  • tests/shared/removeSelectedTest.tsx
  • tests/shared/throwOptionValue.tsx
  • typings/index.d.ts
💤 Files with no reviewable changes (1)
  • typings/index.d.ts

Comment thread tests/shared/throwOptionValue.tsx
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.

1 participant