Skip to content

Avoid rc deep imports#788

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

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

Conversation

@QDyanbing
Copy link
Copy Markdown
Contributor

@QDyanbing QDyanbing commented May 19, 2026

变更内容

  • 升级 @rc-component/util 到当前 latest ^1.11.1,并升级 @rc-component/father-plugin^2.2.0
  • 将源码和测试中对 @rc-component/util/lib/*@rc-component/async-validator/lib/* 的引用改为从包根入口导入。
  • src/index.tsx 补充导出 antd 侧迁移所需的表单类型。

背景

为配合 rc 包统一避免依赖其他 rc 包的 es / lib 构建产物内部路径,改为使用公开根入口 API。

验证

  • git diff --check
  • 此前批量调整中已跑通 npm run compilenpm run lintnpm test

Summary by CodeRabbit

发布说明

  • Chores(维护)
    • 升级 @rc-component/util 和相关开发工具依赖版本,优化性能和稳定性
    • 调整内部模块导入结构,提升代码组织清晰度和可维护性
    • 优化类型导出方式,增强开发者体验

Review Change Stack

@vercel
Copy link
Copy Markdown

vercel Bot commented May 19, 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 19, 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: 5e4cc45e-8cb6-4af7-8cd8-e9c6207e3c47

📥 Commits

Reviewing files that changed from the base of the PR and between f08c1cc and 7db8a68.

📒 Files selected for processing (13)
  • package.json
  • src/Field.tsx
  • src/FieldContext.ts
  • src/List.tsx
  • src/hooks/useForm.ts
  • src/hooks/useWatch.ts
  • src/index.tsx
  • src/utils/delayUtil.ts
  • src/utils/validateUtil.ts
  • src/utils/valueUtil.ts
  • tests/index.test.tsx
  • tests/initialValue.test.tsx
  • tests/list.test.tsx

总体说明

该 PR 统一调整项目对 @rc-component/util 的依赖方式,适配新版本(^1.11.1)的导出结构。核心变化包括依赖升级、导入路径从深层子目录改为顶层包入口、以及公开类型导出的细化。

变更内容

依赖升级与导入路径统一

层级 / 文件 说明
依赖版本升级
package.json
@rc-component/util 从 ^1.6.2 升级至 ^1.11.1;@rc-component/father-plugin 从 ^2.0.1 升级至 ^2.2.0。
核心源文件导入调整
src/Field.tsx, src/FieldContext.ts, src/List.tsx, src/hooks/useForm.ts, src/hooks/useWatch.ts
warningmergeisEqualtoArray 等工具函数的导入从 @rc-component/util/lib/... 深层路径改为从 @rc-component/util 顶层入口统一导入。
工具函数模块导入调整
src/utils/delayUtil.ts, src/utils/validateUtil.ts, src/utils/valueUtil.ts
rafmergewarninggetset 等函数的导入从内部 lib 目录改为从包顶层入口导入。
公开类型导出细化
src/index.tsx
新增 FieldPropsFormProviderProps 等类型导出,将原先批量导出的 FormPropsFormInstance 等扩展为更细粒度的命名导出,包括规则、校验、存储、验证器相关类型。
测试文件导入调整
tests/index.test.tsx, tests/initialValue.test.tsx, tests/list.test.tsx
resetWarned 的导入从 @rc-component/util/lib/warning 改为 @rc-component/util;并调整测试用例中的代码格式。

可能相关的 PR

  • react-component/field-form#776:引入 src/utils/delayUtil.ts 并使用 @rc-component/util/lib/raf,本 PR 将其导入调整为包顶层入口。
  • react-component/field-form#747:同样在多个核心文件中更新 @rc-component/util 的导入来源,调整 warningmergeisEqual 等工具函数的导入方式。

建议审查人

  • zombieJ

代码审查工作量估计

🎯 2 (简单) | ⏱️ ~8 分钟

庆祝诗

🐰 版本升级了,路径更清晰,
顶层入口来,深层路径离,
类型细化出,消费更灵巧,
一行行调整,适配新版妙!

🚥 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 summarizes the main change: replacing deep imports from @rc-component/util with root entry point imports.
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/FieldContext.ts

Oops! Something went wrong! :(

ESLint: 8.57.1

ESLint couldn't find the config "prettier" to extend from. Please check that the name of the config is correct.

The config "prettier" was referenced from the config file in "/.eslintrc.js".

If you still have problems, please stop by https://eslint.org/chat/help to chat with the team.

src/utils/delayUtil.ts

Oops! Something went wrong! :(

ESLint: 8.57.1

ESLint couldn't find the config "prettier" to extend from. Please check that the name of the config is correct.

The config "prettier" was referenced from the config file in "/.eslintrc.js".

If you still have problems, please stop by https://eslint.org/chat/help to chat with the team.

src/hooks/useForm.ts

Oops! Something went wrong! :(

ESLint: 8.57.1

ESLint couldn't find the config "prettier" to extend from. Please check that the name of the config is correct.

The config "prettier" was referenced from the config file in "/.eslintrc.js".

If you still have problems, please stop by https://eslint.org/chat/help to chat with the team.

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

@codecov
Copy link
Copy Markdown

codecov Bot commented May 19, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.54%. Comparing base (f08c1cc) to head (7db8a68).

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #788   +/-   ##
=======================================
  Coverage   99.54%   99.54%           
=======================================
  Files          20       20           
  Lines        1328     1328           
  Branches      325      329    +4     
=======================================
  Hits         1322     1322           
  Misses          6        6           

☔ 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 updates dependencies and refactors imports from @rc-component/util to use the package's main entry point instead of internal paths across the project. It also reorganizes and expands the type exports in the main entry file. Feedback was provided to further increase the API's completeness by exporting additional common types such as FieldData, Callbacks, and ValidateOptions from the root.

Comment thread src/index.tsx
Comment on lines +38 to +52
export type {
FormInstance,
FormRef,
InternalNamePath,
Meta,
NamePath,
Rule,
RuleObject,
RuleRender,
Store,
StoreValue,
ValidateErrorEntity,
ValidateMessages,
ValidatorRule,
} from './interface';
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

建议在此处补充导出更多常用的类型,例如 FieldData, Callbacks, ValidateOptions, ValidateFieldsRuleType。这些类型在外部(如 antd)使用时非常常见,统一从根入口导出可以提升开发体验并保持 API 的完整性。

Suggested change
export type {
FormInstance,
FormRef,
InternalNamePath,
Meta,
NamePath,
Rule,
RuleObject,
RuleRender,
Store,
StoreValue,
ValidateErrorEntity,
ValidateMessages,
ValidatorRule,
} from './interface';
export type {
FormInstance,
FormRef,
InternalNamePath,
Meta,
NamePath,
Rule,
RuleObject,
RuleRender,
Store,
StoreValue,
ValidateErrorEntity,
ValidateMessages,
ValidatorRule,
FieldData,
Callbacks,
ValidateOptions,
ValidateFields,
RuleType,
} from './interface';

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