Skip to content

Avoid rc package deep imports#327

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

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

Conversation

@QDyanbing
Copy link
Copy Markdown
Contributor

@QDyanbing QDyanbing commented May 21, 2026

背景

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

调整内容

  • 升级 @rc-component/father-plugin,使用插件统一拦截 rc 包 lib / es 深路径导入。
  • 升级 @rc-component/util
  • 将源码中 useLayoutEffectcomposeRefuseControlledStateomit 等内部路径引用改为从 @rc-component/util 根入口导入。
  • 未扩大调整测试中的既有 mock 逻辑。

验证

  • npm run lint
  • npm run type:check
  • npm test -- --runInBand
  • npm run compile

Summary by CodeRabbit

Chores

  • 升级核心依赖 @rc-component/util 版本至 ^1.11.1
  • 升级开发依赖 @rc-component/father-plugin 版本至 ^2.2.0
  • 优化内部模块导入结构

Review Change Stack

@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: 33c1d1a1-bfed-4ee3-9c63-95559cc8dfce

📥 Commits

Reviewing files that changed from the base of the PR and between 533ee70 and 25e6800.

📒 Files selected for processing (3)
  • package.json
  • src/MotionThumb.tsx
  • src/index.tsx

总体说明

该 PR 升级了 @rc-component/util 依赖版本(从 ^1.3.0 到 ^1.11.1),并相应调整源代码中的导入路径以使用新版本提供的公开根入口,而非内部子路径。

变更概览

依赖版本升级与导入路径迁移

层级 / 文件 说明
依赖版本升级
package.json
@rc-component/util 升级至 ^1.11.1,@rc-component/father-plugin 升级至 ^2.2.0。
源代码导入路径迁移
src/MotionThumb.tsx, src/index.tsx
useLayoutEffectcomposeRefomituseControlledState 从内部路径(如 @rc-component/util/lib/...)改为从 @rc-component/util 包根入口导入。

代码审查工作量估计

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

可能相关的 PR

  • react-component/segmented#303:同样修改了 src/index.tsx 中的 useControlledState 用法,涉及该工具函数的使用模式。
  • react-component/segmented#298:直接相关,同时调整了 src/MotionThumb.tsxsrc/index.tsx 中从 rc-util 子路径导入到 @rc-component/util 的迁移。

建议审核人

  • zombieJ

诗篇

🐰 依赖跃升至新高度,
包根入口展新路,
内部子路归档案,
导入统一似朝霞,
小兔欢跳庆升级! 🎉

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 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/es)导入,改用根入口点。
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.

@codecov
Copy link
Copy Markdown

codecov Bot commented May 21, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.39%. Comparing base (533ee70) to head (7c18dfe).

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #327      +/-   ##
==========================================
- Coverage   99.40%   99.39%   -0.02%     
==========================================
  Files           2        2              
  Lines         167      164       -3     
  Branches       42       42              
==========================================
- Hits          166      163       -3     
  Misses          1        1              

☔ 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 @rc-component/util and @rc-component/father-plugin dependencies and refactors imports in src/MotionThumb.tsx and src/index.tsx to use the main @rc-component/util package instead of internal paths. Feedback was provided to reorder imports in both files to place the React core library at the top for better consistency and readability.

Comment thread src/index.tsx
Comment on lines +1 to 3
import { composeRef, omit, useControlledState } from '@rc-component/util';
import { clsx } from 'clsx';
import * as React from 'react';
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

建议调整导入顺序,将 react 核心库置于顶部,随后是外部第三方库(如 @rc-component/utilclsx)。这符合 React 开发的通用最佳实践,有助于提高代码的可读性和一致性。

Suggested change
import { composeRef, omit, useControlledState } from '@rc-component/util';
import { clsx } from 'clsx';
import * as React from 'react';
import * as React from 'react';
import { composeRef, omit, useControlledState } from '@rc-component/util';
import { clsx } from 'clsx';

Comment thread src/MotionThumb.tsx
Comment on lines 1 to 4
import CSSMotion from '@rc-component/motion';
import useLayoutEffect from '@rc-component/util/lib/hooks/useLayoutEffect';
import { composeRef } from '@rc-component/util/lib/ref';
import { composeRef, useLayoutEffect } from '@rc-component/util';
import { clsx } from 'clsx';
import * as React from 'react';
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

建议调整导入顺序,将 react 核心库置于顶部。保持一致的导入顺序(React -> 外部库 -> 本地文件)可以提升代码质量和维护性。

Suggested change
import CSSMotion from '@rc-component/motion';
import useLayoutEffect from '@rc-component/util/lib/hooks/useLayoutEffect';
import { composeRef } from '@rc-component/util/lib/ref';
import { composeRef, useLayoutEffect } from '@rc-component/util';
import { clsx } from 'clsx';
import * as React from 'react';
import * as React from 'react';
import CSSMotion from '@rc-component/motion';
import { composeRef, useLayoutEffect } from '@rc-component/util';
import { clsx } from 'clsx';

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