Skip to content

Commit 9b8dcfe

Browse files
committed
Merge branch 'v9.0-integration' into nullable-context
2 parents 6272825 + bec3fa7 commit 9b8dcfe

32 files changed

+3651
-2108
lines changed

.github/workflows/publish.yaml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: Publish Package to npmjs
2+
on:
3+
# keeping it purely manual for now as to not accidentally trigger a release
4+
#release:
5+
# types: [published]
6+
workflow_dispatch:
7+
jobs:
8+
publish:
9+
runs-on: ubuntu-latest
10+
permissions:
11+
id-token: write
12+
contents: read
13+
steps:
14+
- uses: actions/checkout@v3
15+
- uses: actions/setup-node@v3
16+
with:
17+
node-version: '18.x'
18+
registry-url: 'https://registry.npmjs.org'
19+
cache: 'yarn'
20+
- run: yarn install --frozen-lockfile
21+
- run: yarn test
22+
- run: npm publish --access public --provenance
23+
env:
24+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

.github/workflows/test.yml

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ name: Tests
22

33
on:
44
push:
5-
branches: [master, typescript-port]
5+
branches: [master, v9.0-integration]
66
pull_request:
7-
branches: [master, typescript-port]
7+
branches: [master, v9.0-integration]
88
workflow_dispatch:
99

1010
jobs:
@@ -51,7 +51,7 @@ jobs:
5151
fail-fast: false
5252
matrix:
5353
node: ['16.x']
54-
ts: ['4.7', '4.8', '4.9', '5.0']
54+
ts: ['4.7', '4.8', '4.9', '5.0', '5.1']
5555
steps:
5656
- name: Checkout repo
5757
uses: actions/checkout@v3
@@ -73,6 +73,30 @@ jobs:
7373
yarn tsc --version
7474
yarn type-tests
7575
76+
are-the-types-wrong:
77+
name: Check package config with are-the-types-wrong
78+
79+
needs: [build]
80+
runs-on: ubuntu-latest
81+
strategy:
82+
fail-fast: false
83+
matrix:
84+
node: ['16.x']
85+
steps:
86+
- name: Checkout repo
87+
uses: actions/checkout@v3
88+
89+
- uses: actions/download-artifact@v3
90+
with:
91+
name: package
92+
path: .
93+
94+
# Note: We currently expect "FalseCJS" failures for Node16 + `moduleResolution: "node16",
95+
# and the `/alternateRenderers" entry point will not resolve under Node10.
96+
# Skipping these is dangerous, but we'll leave it for now.
97+
- name: Run are-the-types-wrong
98+
run: npx @arethetypeswrong/cli ./package.tgz --format table --ignore-rules false-cjs no-resolution
99+
76100
test-published-artifact-local:
77101
name: Test Published Artifact (Local) ${{ matrix.example }}
78102

.prettierignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
dist/
2+
build*/

.babelrc.js renamed to babel.config.js

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ module.exports = {
1616
},
1717
],
1818
'@babel/preset-typescript',
19+
'module:metro-react-native-babel-preset',
1920
],
2021
plugins: [
2122
['@babel/proposal-decorators', { legacy: true }],
@@ -24,15 +25,6 @@ module.exports = {
2425
['@babel/plugin-proposal-private-methods', { loose: true }],
2526
['@babel/plugin-proposal-private-property-in-object', { loose: true }],
2627
cjs && ['@babel/transform-modules-commonjs'],
27-
[
28-
'@babel/transform-runtime',
29-
{
30-
useESModules: !cjs,
31-
version: require('./package.json').dependencies[
32-
'@babel/runtime'
33-
].replace(/^[^0-9]*/, ''),
34-
},
35-
],
3628
].filter(Boolean),
3729
assumptions: {
3830
enumerableModuleMeta: true,

jest.config.js

Lines changed: 9 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,58 +1,30 @@
1-
const { defaults: tsjPreset } = require('ts-jest/presets')
2-
3-
const defaults = {
4-
coverageDirectory: './coverage/',
5-
collectCoverage: true,
6-
testURL: 'http://localhost',
7-
}
1+
process.env.TS_JEST_DISABLE_VER_CHECKER = true
82

93
const NORMAL_TEST_FOLDERS = ['components', 'hooks', 'integration', 'utils']
104

115
const tsTestFolderPath = (folderName) =>
126
`<rootDir>/test/${folderName}/**/*.{ts,tsx}`
137

148
const tsStandardConfig = {
15-
...defaults,
16-
displayName: 'ReactDOM 18 (Shim)',
9+
displayName: 'ReactDOM 18',
1710
preset: 'ts-jest',
1811
testMatch: NORMAL_TEST_FOLDERS.map(tsTestFolderPath),
12+
testEnvironment: 'jsdom',
13+
setupFilesAfterEnv: ['<rootDir>/jest.setupAfter.js'],
1914
}
2015

2116
const rnConfig = {
22-
...defaults,
2317
displayName: 'React Native',
2418
testMatch: [tsTestFolderPath('react-native')],
2519
preset: 'react-native',
2620
transform: {
27-
'^.+\\.js$': '<rootDir>/node_modules/react-native/jest/preprocessor.js',
28-
...tsjPreset.transform,
29-
},
30-
}
31-
32-
const standardReact17Config = {
33-
...tsStandardConfig,
34-
displayName: 'ReactDOM 17',
35-
moduleNameMapper: {
36-
'^react$': 'react-17',
37-
'^react-dom$': 'react-dom-17',
38-
'^react-test-renderer$': 'react-test-renderer-17',
39-
'^@testing-library/react$': '@testing-library/react-12',
40-
},
41-
}
42-
43-
const nextEntryConfig = {
44-
...tsStandardConfig,
45-
displayName: 'ReactDOM 18 (Next)',
46-
moduleNameMapper: {
47-
'../../src/index': '<rootDir>/src/next',
21+
'^.+\\.(js|jsx|ts|tsx)$': [
22+
'babel-jest',
23+
{ configFile: './babel.config.js' }, // <- cannot use rootDir here
24+
],
4825
},
4926
}
5027

5128
module.exports = {
52-
projects: [
53-
tsStandardConfig,
54-
rnConfig,
55-
standardReact17Config,
56-
nextEntryConfig,
57-
],
29+
projects: [tsStandardConfig, rnConfig],
5830
}

jest.setupAfter.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
const { TextEncoder, TextDecoder } = require('util')
2+
global.TextEncoder = TextEncoder
3+
global.TextDecoder = TextDecoder

package.json

Lines changed: 37 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-redux",
3-
"version": "8.1.1",
3+
"version": "9.0.0-alpha.0",
44
"description": "Official React bindings for Redux",
55
"keywords": [
66
"react",
@@ -12,23 +12,28 @@
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+
"react-server": "./dist/rsc.mjs",
23+
"import": "./dist/react-redux.mjs",
24+
"default": "./dist/cjs/index.js"
25+
},
26+
"./alternate-renderers": {
27+
"types": "./dist/react-redux.d.ts",
28+
"import": "./dist/react-redux.alternate-renderers.mjs"
29+
}
30+
},
1931
"files": [
2032
"dist",
21-
"lib",
22-
"src",
2333
"es"
2434
],
2535
"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",
36+
"build": "tsup",
3237
"clean": "rimraf lib dist es coverage",
3338
"api-types": "api-extractor run --local",
3439
"format": "prettier --write \"{src,test}/**/*.{js,ts,tsx}\" \"docs/**/*.md\"",
@@ -40,12 +45,12 @@
4045
"coverage": "codecov"
4146
},
4247
"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-
"react-native": ">=0.59",
48-
"redux": "^4 || ^5.0.0-beta.0"
48+
"@types/react": "^18.0",
49+
"@types/react-dom": "^18.0",
50+
"react": "^18.0",
51+
"react-dom": "^18.0",
52+
"react-native": ">=0.71",
53+
"redux": "^5.0.0-beta.0"
4954
},
5055
"peerDependenciesMeta": {
5156
"@types/react": {
@@ -65,7 +70,6 @@
6570
}
6671
},
6772
"dependencies": {
68-
"@babel/runtime": "^7.12.1",
6973
"@types/hoist-non-react-statics": "^3.3.1",
7074
"@types/use-sync-external-store": "^0.0.3",
7175
"hoist-non-react-statics": "^3.3.2",
@@ -77,17 +81,14 @@
7781
"@babel/core": "^7.12.3",
7882
"@babel/plugin-proposal-decorators": "^7.12.1",
7983
"@babel/plugin-proposal-object-rest-spread": "^7.12.1",
84+
"@babel/plugin-transform-flow-strip-types": "^7.22.5",
8085
"@babel/plugin-transform-react-display-name": "^7.12.1",
8186
"@babel/plugin-transform-react-jsx": "^7.12.1",
8287
"@babel/plugin-transform-runtime": "^7.12.1",
8388
"@babel/preset-env": "^7.12.1",
8489
"@babel/preset-typescript": "^7.14.5",
8590
"@microsoft/api-extractor": "^7.18.1",
86-
"@reduxjs/toolkit": "^1.9.5",
87-
"@rollup/plugin-babel": "^5.2.1",
88-
"@rollup/plugin-commonjs": "^15.1.0",
89-
"@rollup/plugin-node-resolve": "^9.0.0",
90-
"@rollup/plugin-replace": "^2.3.3",
91+
"@reduxjs/toolkit": "^2.0.0-beta.0",
9192
"@testing-library/jest-dom": "^5.11.5",
9293
"@testing-library/jest-native": "^3.4.3",
9394
"@testing-library/react": "13.0.0",
@@ -102,7 +103,7 @@
102103
"@typescript-eslint/eslint-plugin": "^4.28.0",
103104
"@typescript-eslint/parser": "^4.28.0",
104105
"babel-eslint": "^10.1.0",
105-
"babel-jest": "^26.6.1",
106+
"babel-jest": "^29",
106107
"codecov": "^3.8.0",
107108
"cross-env": "^7.0.2",
108109
"eslint": "^7.12.0",
@@ -111,20 +112,18 @@
111112
"eslint-plugin-prettier": "^3.1.4",
112113
"eslint-plugin-react": "^7.21.5",
113114
"glob": "^7.1.6",
114-
"jest": "^26.6.1",
115+
"jest": "^29",
116+
"jest-environment-jsdom": "^29.5.0",
117+
"metro-react-native-babel-preset": "^0.76.6",
115118
"prettier": "^2.1.2",
116-
"react": "18.0.0",
117-
"react-17": "npm:react@^17",
118-
"react-dom": "18.0.0",
119-
"react-dom-17": "npm:react-dom@^17",
120-
"react-native": "^0.64.1",
119+
"react": "18.2.0",
120+
"react-dom": "18.2.0",
121+
"react-native": "^0.71.11",
121122
"react-test-renderer": "18.0.0",
122-
"react-test-renderer-17": "npm:react-test-renderer@^17",
123-
"redux": "^4.0.5",
123+
"redux": "^5.0.0-beta.0",
124124
"rimraf": "^3.0.2",
125-
"rollup": "^2.32.1",
126-
"rollup-plugin-terser": "^7.0.2",
127-
"ts-jest": "26.5.6",
128-
"typescript": "^4.3.4"
125+
"ts-jest": "^29",
126+
"tsup": "^7.0.0",
127+
"typescript": "^5.0"
129128
}
130129
}

src/alternate-renderers.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
1+
'use client'
2+
13
// The "alternate renderers" entry point is primarily here to fall back on a no-op
24
// version of `unstable_batchedUpdates`, for use with renderers other than ReactDOM/RN.
35
// Examples include React-Three-Fiber, Ink, etc.
4-
// Because of that, we'll also assume the useSyncExternalStore compat shim is needed.
6+
// We'll assume they're built with React 18 and thus have `useSyncExternalStore` available.
57

6-
import { useSyncExternalStore } from 'use-sync-external-store/shim'
7-
import { useSyncExternalStoreWithSelector } from 'use-sync-external-store/shim/with-selector'
8+
import * as React from 'react'
9+
import { useSyncExternalStoreWithSelector } from 'use-sync-external-store/with-selector'
810

911
import { initializeUseSelector } from './hooks/useSelector'
1012
import { initializeConnect } from './components/connect'
1113

1214
initializeUseSelector(useSyncExternalStoreWithSelector)
13-
initializeConnect(useSyncExternalStore)
15+
initializeConnect(React.useSyncExternalStore)
1416

1517
import { getBatch } from './utils/batch'
1618

0 commit comments

Comments
 (0)