Skip to content

Avoid rc package deep imports#1489

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

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

Conversation

@QDyanbing
Copy link
Copy Markdown
Contributor

@QDyanbing QDyanbing commented May 25, 2026

背景

为配合 rc 包统一避免引用其他 rc 包的 es / lib 构建产物内部路径,本次将 table 中相关引用调整为从包根入口导入公开 API。

调整内容

  • 升级 @rc-component/father-plugin@rc-component/util
  • @rc-component/context@rc-component/resize-observer@rc-component/util@rc-component/virtual-list 等深路径引用改为根入口引用
  • 补充 table 根入口导出,方便 antd 和其他 rc 包去除 lib 路径引用
  • 同步调整测试中的相关引用

验证

  • npm run lint 通过,存在既有 warning,无 error

Summary by CodeRabbit

  • New Features

    • 新增导出 convertChildrenToColumns 及多项类型,扩展公共 API 能力。
  • Chores

    • 统一并简化包内导入来源,减少深层子路径引用。
    • 调整与升级内部依赖版本(含新增/移除部分包)。
    • 统一并修正测试导入及全局测试 mock,提升测试兼容性与稳定性。

Review Change Stack

@vercel
Copy link
Copy Markdown

vercel Bot commented May 25, 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 25, 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: 0c9f636e-f0f7-4b89-adf2-2ee7960edf10

📥 Commits

Reviewing files that changed from the base of the PR and between 1a27ddb and 483c2c1.

📒 Files selected for processing (1)
  • src/index.ts

Walkthrough

该 PR 将所有对 @rc-component/util 的深层路径导入统一为包根命名导入,更新 package.json(移除 rc-animate、添加 @rc-component/motion)并扩展入口导出与测试/示例的相应导入与 mock。

Changes

模块导入重构和依赖优化

Layer / File(s) Summary
依赖版本更新与动画库迁移
package.json, docs/examples/animation.tsx
升级 @rc-component/util、升级 @rc-component/father-plugin、新增 @rc-component/motion 并移除 rc-animate;示例中将 CSSMotionListtoArray 的导入切换为新包来源。
核心源码导入整合
src/Table.tsx, src/VirtualTable/index.tsx, src/Cell/useCellRender.ts, src/Body/MeasureCell.tsx, src/Body/MeasureRow.tsx, src/FixedHolder/index.tsx, src/stickyScrollBar.tsx, src/utils/legacyUtil.ts, src/utils/offsetUtil.ts, src/hooks/useColumns/index.tsx, src/hooks/useExpand.ts, src/hooks/useFixedInfo.ts, src/hooks/useSticky.ts, src/index.ts
将多个文件中对 @rc-component/util 的子路径导入统一替换为从包根按命名导入;在 src/Table.tsx 新增并导出 CompareProps<T> 泛型类型,src/index.ts 扩展了若干类型与 convertChildrenToColumns 的导出。
测试文件导入统一
tests/* (多文件)
测试用例中将 resetWarnedspyElementPrototypes 等工具从深路径改为从 @rc-component/util 导入;tests/Virtual.spec.tsx 的 resize 辅助改为使用统一的 onResize
测试环境 Mock 更新
tests/setup.ts
@rc-component/util 进行模块级 mock,固定 getScrollBarSize 返回并新增 getTargetScrollBarSize,以支持依赖滚动条尺寸的测试。

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • react-component/table#1355: 涉及 CompareProps / genTable 类型调整,和本次在 src/Table.tsx 的类型变更存在直接关联。
  • react-component/table#1219: 与本次将 util 导入从深路径迁移到包根入口的改动有较多重叠文件(如 useCellRender、FixedHolder 等)。

Suggested reviewers

  • afc163
  • zombieJ

Poem

🐰 导入归根路更轻,
子路径撤换齐整晴,
动画依赖新风貌,
测试与 mock 同步行,
小兔看代码笑盈盈。

🚥 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 PR标题'Avoid rc package deep imports'准确概括了本次变更的核心目标:避免从rc包的内部深路径(如lib/utils等)导入,改为从包根入口导入公开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/index.ts

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


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 primarily refactors imports to use the root @rc-component/util package instead of deep links, updates dependencies by replacing rc-animate with @rc-component/motion, and expands the public API by exporting additional types and the convertChildrenToColumns utility. Review feedback suggests consolidating the CompareProps type definition by exporting it from Table.tsx and importing it in VirtualTable/index.tsx to avoid duplication and improve consistency across the package.

Comment thread src/Table.tsx Outdated
Comment thread src/VirtualTable/index.tsx Outdated
@socket-security
Copy link
Copy Markdown

socket-security Bot commented May 25, 2026

All alerts resolved. Learn more about Socket for GitHub.

This PR previously contained dependency changes with security issues that have been resolved, removed, or ignored.

View full report

@codecov
Copy link
Copy Markdown

codecov Bot commented May 25, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.10%. Comparing base (d5b5bb1) to head (483c2c1).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1489      +/-   ##
==========================================
- Coverage   96.12%   96.10%   -0.02%     
==========================================
  Files          57       57              
  Lines        3456     3442      -14     
  Branches      639      639              
==========================================
- Hits         3322     3308      -14     
  Misses        129      129              
  Partials        5        5              

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

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