Skip to content

Avoid rc package deep imports#77

Merged
zombieJ merged 3 commits into
react-component:masterfrom
QDyanbing:fix-rc-package-imports
May 18, 2026
Merged

Avoid rc package deep imports#77
zombieJ merged 3 commits into
react-component:masterfrom
QDyanbing:fix-rc-package-imports

Conversation

@QDyanbing
Copy link
Copy Markdown
Contributor

@QDyanbing QDyanbing commented May 15, 2026

背景

antd 升级到 6.4.x 后,在 Yarn PnP、Vite、Vitest、Node 25 等环境下可能直接加载到 rc 包的 es 构建产物内部路径,导致 ESM 加载失败。这个问题暴露出 rc 包之间依赖 es/lib 构建产物内部路径的风险。

变更

  • 增加 no-restricted-imports 规则,禁止从 rc 包的 es/lib 内部路径导入。
  • 将 @rc-component/util 的深路径导入统一改为从包根入口导入。
  • 升级 @rc-component/util 到 ^1.11.0,使用已公开的根入口 API。
  • 从 rc-motion 根入口导出 genCSSMotion,并更新 SSR 示例避免 rc-motion/es/CSSMotion 深路径导入。
  • 移除 tsconfig 中 rc-motion/es/* 路径别名,避免继续鼓励深路径使用。

验证

  • npm run lint:tsc
  • npm run lint
  • npm run compile
  • npm test -- --runInBand
  • 已复扫仓库内 rc 包 es/lib 深路径导入,无命中。

Summary by CodeRabbit

发行说明

  • 新增功能

    • 导出 genCSSMotion 函数和 CSSMotionConfig 类型,为用户提供更灵活的运动配置选项。
  • 依赖更新

    • 升级 @rc-component/util^1.11.0
    • 升级开发依赖 @rc-component/father-plugin^2.2.0
  • 代码优化

    • 简化内部模块导入路径,改进代码组织结构。

Review Change Stack

@vercel
Copy link
Copy Markdown

vercel Bot commented May 15, 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 15, 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: ee3c3aa9-7f0a-40be-a58a-799ab416ad88

📥 Commits

Reviewing files that changed from the base of the PR and between 2363158 and f65c5f0.

📒 Files selected for processing (1)
  • package.json

漫步

该PR通过升级@rc-component/util版本至1.11.0,并调整TypeScript路径配置,实现rc-motion及其依赖的导入路径从内部子路径向包根入口的统一迁移。同时在src/index.tsx扩展公开导出,新增genCSSMotion函数和CSSMotionConfig类型,保持所有核心功能逻辑不变。

变更

导入路径重构与API扩展

层 / 文件 摘要
依赖版本与路径配置更新
package.json, tsconfig.json
升级@rc-component/util至1.11.0版本和@rc-component/father-plugin至2.2.0版本;调整TypeScript路径别名配置,移除rc-motion/es/*映射。
公开API导出扩展
src/index.tsx
新增从./CSSMotion导入genCSSMotion,并在命名导出中同时导出CSSMotionListgenCSSMotion;类型导出列表中新增CSSMotionConfig
模块导入路径统一
src/CSSMotion.tsx, src/hooks/useIsomorphicLayoutEffect.ts, src/hooks/useNextFrame.ts, src/hooks/useStatus.ts, src/hooks/useStepQueue.ts, src/util/motion.ts
getDOMcomposeRefcanUseDomrafuseSyncStateuseState等工具函数导入从各自的@rc-component/util/lib/*内部路径改为统一从@rc-component/util根入口具名导入;canUseDOM更名为canUseDom
文档示例导入适配
docs/examples/ssr.tsx
调整导入方式,改为统一从rc-motion包根导入CSSMotiongenCSSMotion

代码审查工作量估计

🎯 2 (Simple) | ⏱️ ~12 minutes

可能相关的PRs

  • react-component/motion#57:PR对src/CSSMotion.tsxgetNodeRef导入的调整与该PR的CSSMotion引用处理重构存在重叠。
  • react-component/motion#59:主PR对@rc-component/util导入路径的系统性重构与该PR的相应文件导入调整直接重叠。

建议的审核人

  • zombieJ

🐰 导入整顿记

从内部深处归来,
站上包的根处,
API展翅欲飞,
工具函数齐声应答,
一次升级,千般便利。

🚥 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 Pull request title clearly and concisely summarizes the main change: avoiding deep imports from rc packages by consolidating to root entry points.
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.

@QDyanbing QDyanbing marked this pull request as ready for review May 15, 2026 14:15
@codecov
Copy link
Copy Markdown

codecov Bot commented May 15, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.09%. Comparing base (8967d50) to head (f65c5f0).

Additional details and impacted files
@@           Coverage Diff           @@
##           master      #77   +/-   ##
=======================================
  Coverage   98.09%   98.09%           
=======================================
  Files          11       11           
  Lines         421      421           
  Branches      121      120    -1     
=======================================
  Hits          413      413           
  Misses          7        7           
  Partials        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

@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 implements a restriction on importing package internals from 'es' or 'lib' directories by adding a 'no-restricted-imports' ESLint rule. Correspondingly, it refactors imports across the codebase to use package roots for '@rc-component/util' and 'rc-motion'. Additionally, the '@rc-component/util' dependency is updated to version 1.11.0, and 'genCSSMotion' and 'CSSMotionConfig' are now exported from the main index. I have no feedback to provide.

@zombieJ zombieJ merged commit 5b7cb37 into react-component:master May 18, 2026
7 of 8 checks passed
@QDyanbing QDyanbing deleted the fix-rc-package-imports branch May 19, 2026 02:25
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.

2 participants