Skip to content

Commit 5b7cb37

Browse files
authored
Avoid rc package deep imports (#77)
* fix: avoid rc package deep imports * chore: remove local deep import lint rule * chore: bump father-plugin
1 parent 8967d50 commit 5b7cb37

10 files changed

Lines changed: 17 additions & 19 deletions

File tree

docs/examples/ssr.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { clsx } from 'clsx';
2-
import CSSMotion from 'rc-motion';
3-
import { genCSSMotion } from 'rc-motion/es/CSSMotion';
2+
import CSSMotion, { genCSSMotion } from 'rc-motion';
43
import React from 'react';
54
import { hydrate } from 'react-dom';
65
import ReactDOMServer from 'react-dom/server';

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,11 @@
5050
"@types/minimatch": "5.1.2"
5151
},
5252
"dependencies": {
53-
"@rc-component/util": "^1.2.0",
53+
"@rc-component/util": "^1.11.0",
5454
"clsx": "^2.1.1"
5555
},
5656
"devDependencies": {
57-
"@rc-component/father-plugin": "^2.0.1",
57+
"@rc-component/father-plugin": "^2.2.0",
5858
"@rc-component/np": "^1.0.3",
5959
"@testing-library/jest-dom": "^5.16.4",
6060
"@testing-library/react": "^15.0.7",

src/CSSMotion.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
/* eslint-disable react/default-props-match-prop-types, react/no-multi-comp, react/prop-types */
2-
import { getDOM } from '@rc-component/util/lib/Dom/findDOMNode';
32
import {
43
composeRef,
4+
getDOM,
55
getNodeRef,
66
supportNodeRef,
7-
} from '@rc-component/util/lib/ref';
7+
} from '@rc-component/util';
88
import { clsx } from 'clsx';
99
import * as React from 'react';
1010
import { useRef } from 'react';

src/hooks/useIsomorphicLayoutEffect.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import canUseDom from '@rc-component/util/lib/Dom/canUseDom';
1+
import { canUseDom } from '@rc-component/util';
22
import { useEffect, useLayoutEffect } from 'react';
33

44
// It's safe to use `useLayoutEffect` but the warning is annoying

src/hooks/useNextFrame.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import raf from '@rc-component/util/lib/raf';
1+
import { raf } from '@rc-component/util';
22
import * as React from 'react';
33

44
export default (): [

src/hooks/useStatus.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import { useEvent } from '@rc-component/util';
2-
import useSyncState from '@rc-component/util/lib/hooks/useSyncState';
1+
import { useEvent, useSyncState } from '@rc-component/util';
32
import * as React from 'react';
43
import { useEffect, useRef } from 'react';
54
import type { CSSMotionProps } from '../CSSMotion';

src/hooks/useStepQueue.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import useState from '@rc-component/util/lib/hooks/useState';
1+
import { useState } from '@rc-component/util';
22
import * as React from 'react';
33
import type { MotionStatus, StepStatus } from '../interface';
44
import {

src/index.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
import type { CSSMotionProps } from './CSSMotion';
2-
import CSSMotion from './CSSMotion';
1+
import type { CSSMotionConfig, CSSMotionProps } from './CSSMotion';
2+
import CSSMotion, { genCSSMotion } from './CSSMotion';
33
import type { CSSMotionListProps } from './CSSMotionList';
44
import CSSMotionList from './CSSMotionList';
55
import type { MotionEndEventHandler, MotionEventHandler } from './interface';
66
export { default as Provider } from './context';
7-
export { CSSMotionList };
7+
export { CSSMotionList, genCSSMotion };
88
export type {
9+
CSSMotionConfig,
910
CSSMotionProps,
1011
CSSMotionListProps,
1112
MotionEventHandler,

src/util/motion.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import canUseDOM from '@rc-component/util/lib/Dom/canUseDom';
1+
import { canUseDom } from '@rc-component/util';
22
import type { MotionName } from '../CSSMotion';
33

44
// ================= Transition =================
@@ -38,13 +38,13 @@ export function getVendorPrefixes(domSupport: boolean, win: object) {
3838
}
3939

4040
const vendorPrefixes = getVendorPrefixes(
41-
canUseDOM(),
41+
canUseDom(),
4242
typeof window !== 'undefined' ? window : {},
4343
);
4444

4545
let style = {};
4646

47-
if (canUseDOM()) {
47+
if (canUseDom()) {
4848
({ style } = document.createElement('div'));
4949
}
5050

tsconfig.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@
1010
"paths": {
1111
"@/*": ["src/*"],
1212
"@@/*": ["src/.umi/*"],
13-
"rc-motion": ["src/index.tsx"],
14-
"rc-motion/es/*": ["src/*"]
13+
"rc-motion": ["src/index.tsx"]
1514
}
1615
}
1716
}

0 commit comments

Comments
 (0)