Skip to content

Avoid rc package deep imports#603

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

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

Conversation

@QDyanbing
Copy link
Copy Markdown

@QDyanbing QDyanbing commented May 22, 2026

背景

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

调整内容

  • 升级 @rc-component/father-plugin,使用插件统一拦截 rc 包 lib / es 深路径导入。
  • 升级 @rc-component/util
  • 将源码中 useLayoutEffectpickAttrsuseComposeRefuseLockFocususeEventcanUseDomwarning 等内部路径引用改为从 @rc-component/util 根入口导入。
  • 同步调整 focus 测试中的 useLockFocus mock 目标,保留原有测试语义。
  • 补充导出 DrawerPopupProps 类型。
  • 移除不再需要的 util deep-path 类型声明。

验证

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

Summary by CodeRabbit

发布说明

  • 新功能

    • 新增 DrawerPopupProps 类型导出,增强类型系统的完整性。
  • 依赖更新

    • 升级 @rc-component/util 至 ^1.11.1 版本。
    • 升级 @rc-component/father-plugin 至 ^2.2.0 版本。

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

coderabbitai Bot commented May 22, 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: 8feee22e-2589-4863-8196-6add675ea3d8

📥 Commits

Reviewing files that changed from the base of the PR and between 6a52ca1 and 0f1fcad.

📒 Files selected for processing (10)
  • package.json
  • src/Drawer.tsx
  • src/DrawerPanel.tsx
  • src/DrawerPopup.tsx
  • src/hooks/useFocusable.ts
  • src/index.ts
  • src/util.ts
  • tests/focus.spec.tsx
  • tests/index.spec.tsx
  • typings/custom.d.ts
💤 Files with no reviewable changes (1)
  • typings/custom.d.ts

演进说明

本 PR 对 react-component/drawer 进行了一次导入路径的系统升级。通过将 @rc-component/util^1.9.0 升级至 ^1.11.1,库的公开 API 现已暴露了原先仅在内部 lib/* 子路径中的工具函数,使得全库可以统一从包入口直接导入,无需依赖深层路径。

变更概述

该 PR 统一了 Drawer 组件库对 @rc-component/util 的导入方式,并清理了相应的类型声明文件。

变更范围

层级 / 文件(s) 概述
依赖升级与类型导出
package.json, src/index.ts
@rc-component/util 升至 ^1.11.1@rc-component/father-plugin 升至 ^2.2.0;新增 DrawerPopupProps 类型重导出。
源代码导入迁移
src/Drawer.tsx, src/DrawerPanel.tsx, src/DrawerPopup.tsx, src/hooks/useFocusable.ts, src/util.ts
统一将 useLayoutEffectpickAttrsuseComposeRefuseLockFocuscanUseDomwarning 等工具从深层 @rc-component/util/lib/* 路径改为直接从 @rc-component/util 命名导入。
测试与类型声明调整
tests/focus.spec.tsx, tests/index.spec.tsx, typings/custom.d.ts
更新 Jest 模拟配置以适配新导入路径;移除针对 @rc-component/util/lib/* 的自定义类型声明,仅保留 raf 模块声明。

预估评审工作量

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

可能相关的 PR

建议的评审者

  • zombieJ

庆祝诗

🐰 依赖升升新,导入路更清,
深藏的工具现身,包入口直呼应。
类型声明整理妥,测试 mock 也适配,
一统江湖导入路,代码清爽更有序。✨

🚥 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 拉取请求标题准确总结了主要变更:将内部深层导入改为从 @rc-component 包根路径导入,避免直接访问 lib/es 子路径。
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/Drawer.tsx

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

src/DrawerPanel.tsx

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

src/DrawerPopup.tsx

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

  • 5 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.

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 dependency to version 1.11.1 and refactors the codebase to use named imports from the package root instead of deep imports from the /lib directory. Additionally, DrawerPopupProps is now exported from the main entry point, and obsolete module declarations in typings/custom.d.ts have been removed. I have no feedback to provide.

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