Skip to content

Commit 918e7e9

Browse files
authored
Consolidate entry points (#1761)
1 parent 17ddf9d commit 918e7e9

6 files changed

+77
-89
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"repository": "github:reduxjs/react-redux",
1414
"bugs": "https://github.com/reduxjs/react-redux/issues",
1515
"main": "./lib/index.js",
16-
"types": "./lib/index.d.ts",
16+
"types": "./es/index.d.ts",
1717
"unpkg": "dist/react-redux.js",
1818
"module": "es/index.js",
1919
"files": [

src/alternate-renderers.js

-26
This file was deleted.

src/alternate-renderers.ts

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
export * from './exports'
2+
3+
import { getBatch } from './utils/batch'
4+
5+
// For other renderers besides ReactDOM and React Native,
6+
// use the default noop batch function
7+
const batch = getBatch()
8+
9+
export { batch }

src/exports.ts

+61
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
import Provider from './components/Provider'
2+
import type { ProviderProps } from './components/Provider'
3+
import connectAdvanced from './components/connectAdvanced'
4+
import type {
5+
ConnectAdvancedOptions,
6+
ConnectProps,
7+
} from './components/connectAdvanced'
8+
import type {
9+
SelectorFactory,
10+
Selector,
11+
MapStateToProps,
12+
MapStateToPropsFactory,
13+
MapStateToPropsParam,
14+
MapDispatchToPropsFunction,
15+
MapDispatchToProps,
16+
MapDispatchToPropsFactory,
17+
MapDispatchToPropsParam,
18+
MapDispatchToPropsNonObject,
19+
MergeProps,
20+
} from './connect/selectorFactory'
21+
import { ReactReduxContext } from './components/Context'
22+
import type { ReactReduxContextValue } from './components/Context'
23+
import connect from './connect/connect'
24+
25+
import { useDispatch, createDispatchHook } from './hooks/useDispatch'
26+
import { useSelector, createSelectorHook } from './hooks/useSelector'
27+
import { useStore, createStoreHook } from './hooks/useStore'
28+
29+
import shallowEqual from './utils/shallowEqual'
30+
31+
export * from './types'
32+
export type {
33+
ProviderProps,
34+
SelectorFactory,
35+
Selector,
36+
MapStateToProps,
37+
MapStateToPropsFactory,
38+
MapStateToPropsParam,
39+
ConnectProps,
40+
ConnectAdvancedOptions,
41+
MapDispatchToPropsFunction,
42+
MapDispatchToProps,
43+
MapDispatchToPropsFactory,
44+
MapDispatchToPropsParam,
45+
MapDispatchToPropsNonObject,
46+
MergeProps,
47+
ReactReduxContextValue,
48+
}
49+
export {
50+
Provider,
51+
connectAdvanced,
52+
ReactReduxContext,
53+
connect,
54+
useDispatch,
55+
createDispatchHook,
56+
useSelector,
57+
createSelectorHook,
58+
useStore,
59+
createStoreHook,
60+
shallowEqual,
61+
}

src/index.ts

+5-61
Original file line numberDiff line numberDiff line change
@@ -1,66 +1,10 @@
1-
import Provider from './components/Provider'
2-
import type { ProviderProps } from './components/Provider'
3-
import connectAdvanced from './components/connectAdvanced'
4-
import type {
5-
ConnectAdvancedOptions,
6-
ConnectProps,
7-
} from './components/connectAdvanced'
8-
import type {
9-
SelectorFactory,
10-
Selector,
11-
MapStateToProps,
12-
MapStateToPropsFactory,
13-
MapStateToPropsParam,
14-
MapDispatchToPropsFunction,
15-
MapDispatchToProps,
16-
MapDispatchToPropsFactory,
17-
MapDispatchToPropsParam,
18-
MapDispatchToPropsNonObject,
19-
MergeProps,
20-
} from './connect/selectorFactory'
21-
import { ReactReduxContext } from './components/Context'
22-
import type { ReactReduxContextValue } from './components/Context'
23-
import connect from './connect/connect'
1+
export * from './exports'
242

25-
import { useDispatch, createDispatchHook } from './hooks/useDispatch'
26-
import { useSelector, createSelectorHook } from './hooks/useSelector'
27-
import { useStore, createStoreHook } from './hooks/useStore'
28-
29-
import { setBatch } from './utils/batch'
303
import { unstable_batchedUpdates as batch } from './utils/reactBatchedUpdates'
31-
import shallowEqual from './utils/shallowEqual'
4+
import { setBatch } from './utils/batch'
325

6+
// Enable batched updates in our subscriptions for use
7+
// with standard React renderers (ReactDOM, React Native)
338
setBatch(batch)
349

35-
export * from './types'
36-
export type {
37-
ProviderProps,
38-
SelectorFactory,
39-
Selector,
40-
MapStateToProps,
41-
MapStateToPropsFactory,
42-
MapStateToPropsParam,
43-
ConnectProps,
44-
ConnectAdvancedOptions,
45-
MapDispatchToPropsFunction,
46-
MapDispatchToProps,
47-
MapDispatchToPropsFactory,
48-
MapDispatchToPropsParam,
49-
MapDispatchToPropsNonObject,
50-
MergeProps,
51-
ReactReduxContextValue,
52-
}
53-
export {
54-
Provider,
55-
connectAdvanced,
56-
ReactReduxContext,
57-
connect,
58-
batch,
59-
useDispatch,
60-
createDispatchHook,
61-
useSelector,
62-
createSelectorHook,
63-
useStore,
64-
createStoreHook,
65-
shallowEqual,
66-
}
10+
export { batch }

tsconfig.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"jsx": "react",
1111
"declaration": true,
1212
"emitDeclarationOnly": true,
13-
"outDir": "./lib",
13+
"outDir": "./es",
1414
"forceConsistentCasingInFileNames": true
1515
},
1616
"include": ["src/**/*", "types"],

0 commit comments

Comments
 (0)