From 236315864bf000de3b6bebadfc5f24ecb61a2466 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=AB=98=E8=89=B3=E5=85=B5?= Date: Fri, 15 May 2026 22:12:45 +0800 Subject: [PATCH 1/3] fix: avoid rc package deep imports --- .eslintrc.js | 23 +++++++++++++++++++++++ docs/examples/ssr.tsx | 3 +-- package.json | 2 +- src/CSSMotion.tsx | 4 ++-- src/hooks/useIsomorphicLayoutEffect.ts | 2 +- src/hooks/useNextFrame.ts | 2 +- src/hooks/useStatus.ts | 3 +-- src/hooks/useStepQueue.ts | 2 +- src/index.tsx | 7 ++++--- src/util/motion.ts | 6 +++--- tsconfig.json | 3 +-- 11 files changed, 39 insertions(+), 18 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index 25c9491..4eda059 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -1,6 +1,29 @@ +const restrictedPackageDirectoryImports = [ + '@rc-component/*/es', + '@rc-component/*/es/**', + '@rc-component/*/lib', + '@rc-component/*/lib/**', + 'rc-*/es', + 'rc-*/es/**', + 'rc-*/lib', + 'rc-*/lib/**', +]; + module.exports = { extends: [require.resolve('@umijs/fabric/dist/eslint')], rules: { + 'no-restricted-imports': [ + 'error', + { + patterns: [ + { + group: restrictedPackageDirectoryImports, + message: + 'Do not import package internals from es/lib. Import from the package root.', + }, + ], + }, + ], 'no-template-curly-in-string': 0, 'prefer-promise-reject-errors': 0, 'react/no-array-index-key': 0, diff --git a/docs/examples/ssr.tsx b/docs/examples/ssr.tsx index f763a7b..95b06d1 100644 --- a/docs/examples/ssr.tsx +++ b/docs/examples/ssr.tsx @@ -1,6 +1,5 @@ import { clsx } from 'clsx'; -import CSSMotion from 'rc-motion'; -import { genCSSMotion } from 'rc-motion/es/CSSMotion'; +import CSSMotion, { genCSSMotion } from 'rc-motion'; import React from 'react'; import { hydrate } from 'react-dom'; import ReactDOMServer from 'react-dom/server'; diff --git a/package.json b/package.json index 8cf3466..3faaa2f 100644 --- a/package.json +++ b/package.json @@ -50,7 +50,7 @@ "@types/minimatch": "5.1.2" }, "dependencies": { - "@rc-component/util": "^1.2.0", + "@rc-component/util": "^1.11.0", "clsx": "^2.1.1" }, "devDependencies": { diff --git a/src/CSSMotion.tsx b/src/CSSMotion.tsx index c1ec2c2..f23148b 100644 --- a/src/CSSMotion.tsx +++ b/src/CSSMotion.tsx @@ -1,10 +1,10 @@ /* eslint-disable react/default-props-match-prop-types, react/no-multi-comp, react/prop-types */ -import { getDOM } from '@rc-component/util/lib/Dom/findDOMNode'; import { composeRef, + getDOM, getNodeRef, supportNodeRef, -} from '@rc-component/util/lib/ref'; +} from '@rc-component/util'; import { clsx } from 'clsx'; import * as React from 'react'; import { useRef } from 'react'; diff --git a/src/hooks/useIsomorphicLayoutEffect.ts b/src/hooks/useIsomorphicLayoutEffect.ts index e2a6211..11111d5 100644 --- a/src/hooks/useIsomorphicLayoutEffect.ts +++ b/src/hooks/useIsomorphicLayoutEffect.ts @@ -1,4 +1,4 @@ -import canUseDom from '@rc-component/util/lib/Dom/canUseDom'; +import { canUseDom } from '@rc-component/util'; import { useEffect, useLayoutEffect } from 'react'; // It's safe to use `useLayoutEffect` but the warning is annoying diff --git a/src/hooks/useNextFrame.ts b/src/hooks/useNextFrame.ts index 0ee9604..5125f19 100644 --- a/src/hooks/useNextFrame.ts +++ b/src/hooks/useNextFrame.ts @@ -1,4 +1,4 @@ -import raf from '@rc-component/util/lib/raf'; +import { raf } from '@rc-component/util'; import * as React from 'react'; export default (): [ diff --git a/src/hooks/useStatus.ts b/src/hooks/useStatus.ts index 9795d30..aad729d 100644 --- a/src/hooks/useStatus.ts +++ b/src/hooks/useStatus.ts @@ -1,5 +1,4 @@ -import { useEvent } from '@rc-component/util'; -import useSyncState from '@rc-component/util/lib/hooks/useSyncState'; +import { useEvent, useSyncState } from '@rc-component/util'; import * as React from 'react'; import { useEffect, useRef } from 'react'; import type { CSSMotionProps } from '../CSSMotion'; diff --git a/src/hooks/useStepQueue.ts b/src/hooks/useStepQueue.ts index 05362c0..5b3fefd 100644 --- a/src/hooks/useStepQueue.ts +++ b/src/hooks/useStepQueue.ts @@ -1,4 +1,4 @@ -import useState from '@rc-component/util/lib/hooks/useState'; +import { useState } from '@rc-component/util'; import * as React from 'react'; import type { MotionStatus, StepStatus } from '../interface'; import { diff --git a/src/index.tsx b/src/index.tsx index 2fa1f88..efd7b3c 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -1,11 +1,12 @@ -import type { CSSMotionProps } from './CSSMotion'; -import CSSMotion from './CSSMotion'; +import type { CSSMotionConfig, CSSMotionProps } from './CSSMotion'; +import CSSMotion, { genCSSMotion } from './CSSMotion'; import type { CSSMotionListProps } from './CSSMotionList'; import CSSMotionList from './CSSMotionList'; import type { MotionEndEventHandler, MotionEventHandler } from './interface'; export { default as Provider } from './context'; -export { CSSMotionList }; +export { CSSMotionList, genCSSMotion }; export type { + CSSMotionConfig, CSSMotionProps, CSSMotionListProps, MotionEventHandler, diff --git a/src/util/motion.ts b/src/util/motion.ts index d2a60d9..6b47070 100644 --- a/src/util/motion.ts +++ b/src/util/motion.ts @@ -1,4 +1,4 @@ -import canUseDOM from '@rc-component/util/lib/Dom/canUseDom'; +import { canUseDom } from '@rc-component/util'; import type { MotionName } from '../CSSMotion'; // ================= Transition ================= @@ -38,13 +38,13 @@ export function getVendorPrefixes(domSupport: boolean, win: object) { } const vendorPrefixes = getVendorPrefixes( - canUseDOM(), + canUseDom(), typeof window !== 'undefined' ? window : {}, ); let style = {}; -if (canUseDOM()) { +if (canUseDom()) { ({ style } = document.createElement('div')); } diff --git a/tsconfig.json b/tsconfig.json index f6b7656..6ff0503 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -10,8 +10,7 @@ "paths": { "@/*": ["src/*"], "@@/*": ["src/.umi/*"], - "rc-motion": ["src/index.tsx"], - "rc-motion/es/*": ["src/*"] + "rc-motion": ["src/index.tsx"] } } } From 71904c36b199fe1cf5fd5e2027b3a2ed6ba25173 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=AB=98=E8=89=B3=E5=85=B5?= Date: Sun, 17 May 2026 09:20:39 +0800 Subject: [PATCH 2/3] chore: remove local deep import lint rule --- .eslintrc.js | 23 ----------------------- 1 file changed, 23 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index 4eda059..25c9491 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -1,29 +1,6 @@ -const restrictedPackageDirectoryImports = [ - '@rc-component/*/es', - '@rc-component/*/es/**', - '@rc-component/*/lib', - '@rc-component/*/lib/**', - 'rc-*/es', - 'rc-*/es/**', - 'rc-*/lib', - 'rc-*/lib/**', -]; - module.exports = { extends: [require.resolve('@umijs/fabric/dist/eslint')], rules: { - 'no-restricted-imports': [ - 'error', - { - patterns: [ - { - group: restrictedPackageDirectoryImports, - message: - 'Do not import package internals from es/lib. Import from the package root.', - }, - ], - }, - ], 'no-template-curly-in-string': 0, 'prefer-promise-reject-errors': 0, 'react/no-array-index-key': 0, From f65c5f042ae98711b5b09ede6001292bd517bbb2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=AB=98=E8=89=B3=E5=85=B5?= Date: Mon, 18 May 2026 11:50:02 +0800 Subject: [PATCH 3/3] chore: bump father-plugin --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 3faaa2f..e442ac4 100644 --- a/package.json +++ b/package.json @@ -54,7 +54,7 @@ "clsx": "^2.1.1" }, "devDependencies": { - "@rc-component/father-plugin": "^2.0.1", + "@rc-component/father-plugin": "^2.2.0", "@rc-component/np": "^1.0.3", "@testing-library/jest-dom": "^5.16.4", "@testing-library/react": "^15.0.7",