Skip to content

Avoid rc package deep imports#732

Open
QDyanbing wants to merge 2 commits into
react-component:masterfrom
QDyanbing:avoid-deep-imports
Open

Avoid rc package deep imports#732
QDyanbing wants to merge 2 commits into
react-component:masterfrom
QDyanbing:avoid-deep-imports

Conversation

@QDyanbing
Copy link
Copy Markdown

@QDyanbing QDyanbing commented May 21, 2026

背景

antd 侧限制继续使用 rc 包的 lib / es 深路径导入,需要将 input-number 中对 rc 包内部路径的依赖迁移到包根入口。

调整内容

  • 升级 @rc-component/father-plugin,使用插件统一拦截 rc 包 lib / es 深路径导入。
  • 升级 @rc-component/util,将源码和测试中对 KeyCoderafwarning、hooks、DOM 工具等内部路径的引用改为从 @rc-component/util 根入口导入。
  • 保留 click.test.tsx 中原有的 mini-decimal mock 方式,仅替换 KeyCode 导入,避免扩大测试行为改动。
  • 整理相关测试文件的导入顺序和格式。

验证

  • npm run lint
  • npm test -- --runInBand
  • npm run compile

Summary by CodeRabbit

发行说明

  • Chores
    • 升级运行时依赖 @rc-component/util 至最新版本,获得更好的性能和兼容性支持
    • 升级开发依赖 @rc-component/father-plugin 以支持新的构建工具链
    • 调整内部导入方式以适配依赖包的最新导出结构

Review Change Stack

@vercel
Copy link
Copy Markdown

vercel Bot commented May 21, 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

coderabbitai Bot commented May 21, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: ea213e92-11c4-4723-8531-ec1f525590ad

📥 Commits

Reviewing files that changed from the base of the PR and between 88c6a43 and 2c6b771.

📒 Files selected for processing (15)
  • package.json
  • src/InputNumber.tsx
  • src/StepHandler.tsx
  • src/hooks/useCursor.ts
  • src/hooks/useFrame.ts
  • tests/click.test.tsx
  • tests/cursor.test.tsx
  • tests/focus.test.tsx
  • tests/formatter.test.tsx
  • tests/github.test.tsx
  • tests/input.test.tsx
  • tests/keyboard.test.tsx
  • tests/precision.test.tsx
  • tests/props.test.tsx
  • tests/wheel.test.tsx

总体说明

将项目内 @rc-component/util 的依赖升级至 ^1.11.1,并系统地调整源码和测试文件中的导入路径,从 lib/* 子路径迁移为从包入口直接导入相关工具函数。

变更内容

@rc-component/util 导入路径统一迁移

层级 / 文件 摘要
依赖升级与源码导入调整
package.json, src/InputNumber.tsx, src/StepHandler.tsx, src/hooks/useCursor.ts, src/hooks/useFrame.ts
@rc-component/util 版本从 ^1.4.0 升至 ^1.11.1,并将源码中 InputFocusOptionsproxyObjecttriggerFocususeEventuseLayoutUpdateEffectrafwarning 等工具的导入方式从 lib/* 子路径改为从包入口直接导入。
测试文件导入更新与代码调整
tests/click.test.tsx, tests/cursor.test.tsx, tests/focus.test.tsx, tests/formatter.test.tsx, tests/github.test.tsx, tests/input.test.tsx, tests/keyboard.test.tsx, tests/precision.test.tsx, tests/props.test.tsx, tests/wheel.test.tsx
统一更新所有测试文件中 KeyCodespyElementPrototypes 的导入来源为 @rc-component/util 包入口,并调整部分测试中事件参数的结构化写法(如 fireEvent.changetarget 对象、keyboard 事件的 key 参数)以及断言格式的统一。

预估代码审查工作量

🎯 2 (Simple) | ⏱️ ~12 分钟

可能相关的 PR

  • react-component/input-number#696: 同样涉及 @rc-component/util 导入路径更新,在相同的源文件和测试文件中统一调整 KeyCode/raf/warning 等符号的导入方式。

建议审查人员

  • afc163
  • zombieJ

🐰 兔子漫步在模块的花园里,
导入路径焕然一新,整齐如初。
从深层的 lib 走出,
拥抱包裹主入口的光芒。
一次迁移,万般测试皆通过!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ 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%. 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 该标题准确总结了 PR 的主要目标:避免对 rc 包的深层导入,与所有代码更改(升级依赖、调整导入路径从 lib/* 改为根入口)完全对应。
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

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.

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 project's dependencies, specifically upgrading @rc-component/util and @rc-component/father-plugin. The main code changes involve refactoring imports across the codebase to use top-level named imports from @rc-component/util instead of deep path imports. Additionally, several test files received minor formatting and linting improvements. A review comment suggests further consolidating imports in src/InputNumber.tsx by using inline type imports for better conciseness.

Comment thread src/InputNumber.tsx Outdated
Comment on lines +9 to +10
import type { InputFocusOptions } from '@rc-component/util';
import { proxyObject, triggerFocus, useEvent, useLayoutUpdateEffect } from '@rc-component/util';
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

可以将来自同一个包的类型导入和普通导入合并,使代码更加简洁。由于项目使用了 TypeScript 5.1,支持在命名导入中使用 type 前缀。

Suggested change
import type { InputFocusOptions } from '@rc-component/util';
import { proxyObject, triggerFocus, useEvent, useLayoutUpdateEffect } from '@rc-component/util';
import { type InputFocusOptions, proxyObject, triggerFocus, useEvent, useLayoutUpdateEffect } from '@rc-component/util';

@QDyanbing
Copy link
Copy Markdown
Author

Refs ant-design/ant-design#58115

antd 侧统一跟踪 rc 包 es/lib 深路径引用问题。

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