Skip to content

Commit 9f55732

Browse files
committed
Switch build+package setup to use tsup
1 parent 247a41e commit 9f55732

File tree

2 files changed

+26
-19
lines changed

2 files changed

+26
-19
lines changed

package.json

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -12,23 +12,27 @@
1212
"homepage": "https://github.com/reduxjs/react-redux",
1313
"repository": "github:reduxjs/react-redux",
1414
"bugs": "https://github.com/reduxjs/react-redux/issues",
15-
"main": "./lib/index.js",
16-
"types": "./es/index.d.ts",
17-
"unpkg": "dist/react-redux.js",
18-
"module": "es/index.js",
15+
"module": "dist/react-redux.legacy-esm.js",
16+
"main": "dist/cjs/index.js",
17+
"types": "dist/react-redux.d.ts",
18+
"exports": {
19+
"./package.json": "./package.json",
20+
".": {
21+
"types": "./dist/react-redux.d.ts",
22+
"import": "./dist/react-redux.mjs",
23+
"default": "./dist/cjs/index.js"
24+
},
25+
"./alternate-renderers": {
26+
"types": "./dist/react-redux.d.ts",
27+
"import": "./dist/react-redux.alternate-renderers.mjs"
28+
}
29+
},
1930
"files": [
2031
"dist",
21-
"lib",
22-
"src",
2332
"es"
2433
],
2534
"scripts": {
26-
"build:commonjs": "cross-env BABEL_ENV=commonjs babel src --extensions \".js,.ts,.tsx\" --out-dir lib",
27-
"build:es": "babel src --extensions \".js,.ts,.tsx\" --out-dir es",
28-
"build:umd": "cross-env NODE_ENV=development rollup -c -o dist/react-redux.js",
29-
"build:umd:min": "cross-env NODE_ENV=production rollup -c -o dist/react-redux.min.js",
30-
"build:types": "tsc",
31-
"build": "yarn build:types && yarn build:commonjs && yarn build:es && yarn build:umd && yarn build:umd:min",
35+
"build": "tsup",
3236
"clean": "rimraf lib dist es coverage",
3337
"api-types": "api-extractor run --local",
3438
"format": "prettier --write \"{src,test}/**/*.{js,ts,tsx}\" \"docs/**/*.md\"",
@@ -40,10 +44,10 @@
4044
"coverage": "codecov"
4145
},
4246
"peerDependencies": {
43-
"@types/react": "^16.8 || ^17.0 || ^18.0",
44-
"@types/react-dom": "^16.8 || ^17.0 || ^18.0",
45-
"react": "^16.8 || ^17.0 || ^18.0",
46-
"react-dom": "^16.8 || ^17.0 || ^18.0",
47+
"@types/react": "^18.0",
48+
"@types/react-dom": "^18.0",
49+
"react": "^18.0",
50+
"react-dom": "^18.0",
4751
"react-native": ">=0.59",
4852
"redux": "^4 || ^5.0.0-beta.0"
4953
},
@@ -65,7 +69,6 @@
6569
}
6670
},
6771
"dependencies": {
68-
"@babel/runtime": "^7.12.1",
6972
"@types/hoist-non-react-statics": "^3.3.1",
7073
"@types/use-sync-external-store": "^0.0.3",
7174
"hoist-non-react-statics": "^3.3.2",

src/index.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import { useSyncExternalStore } from 'use-sync-external-store/shim'
66
import { useSyncExternalStoreWithSelector } from 'use-sync-external-store/shim/with-selector'
77

8-
import { unstable_batchedUpdates as batch } from './utils/reactBatchedUpdates'
8+
import { unstable_batchedUpdates as batchInternal } from './utils/reactBatchedUpdates'
99
import { setBatch } from './utils/batch'
1010

1111
import { initializeUseSelector } from './hooks/useSelector'
@@ -16,7 +16,11 @@ initializeConnect(useSyncExternalStore)
1616

1717
// Enable batched updates in our subscriptions for use
1818
// with standard React renderers (ReactDOM, React Native)
19-
setBatch(batch)
19+
setBatch(batchInternal)
20+
21+
// Avoid needing `react-dom` in the final TS types
22+
// by providing a simpler type for `batch`
23+
const batch: (cb: () => void) => void = batchInternal
2024

2125
export { batch }
2226

0 commit comments

Comments
 (0)