Skip to content

Commit b718e01

Browse files
authored
Merge pull request #1016 from reduxjs/feature/v1.6-integration
2 parents 4ad8be6 + 034bdec commit b718e01

File tree

431 files changed

+46725
-21423
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

431 files changed

+46725
-21423
lines changed

.codesandbox/ci.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
"sandboxes": [
33
"vanilla",
44
"vanilla-ts",
5-
"github/reduxjs/rtk-github-issues-example"
5+
"github/reduxjs/rtk-github-issues-example",
6+
"github/reduxjs/toolkit/examples/query/react/optimistic-updates"
67
],
78
"node": "14"
8-
}
9+
}

.eslintrc.js

Lines changed: 41 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,50 @@
11
module.exports = {
2-
extends: [
3-
'react-app',
4-
'prettier/@typescript-eslint',
5-
'plugin:prettier/recommended'
6-
],
2+
extends: ['react-app', 'prettier'],
73
parser: '@typescript-eslint/parser',
84
rules: {
95
'jsx-a11y/href-no-hash': 'off',
106
// Taken care of by TypeScript's `noUnusedLocals` / `noUnusedParameters`
117
'no-unused-vars': 'off',
128
'@typescript-eslint/no-unused-vars': 'off',
139
// Silence some bizarre "rule not found" TSLint error
14-
'@typescript-eslint/no-angle-bracket-type-assertion': 'off'
15-
}
10+
'@typescript-eslint/no-angle-bracket-type-assertion': 'off',
11+
'no-redeclare': 'off',
12+
// Silence some bizarre "rule not found" TSLint error
13+
'@typescript-eslint/no-redeclare': 'off',
14+
'no-use-before-define': 'off',
15+
'@typescript-eslint/no-use-before-define': ['error', { functions: false }],
16+
'@typescript-eslint/consistent-type-imports': [
17+
'error',
18+
{ prefer: 'type-imports', disallowTypeAnnotations: false },
19+
],
20+
},
21+
overrides: [
22+
// {
23+
// // only add after https://github.com/typescript-eslint/typescript-eslint/pull/3463 is merged
24+
// files: ['src/**/*.ts'],
25+
// excludedFiles: [
26+
// '**/tests/*.ts',
27+
// '**/tests/**/*.ts',
28+
// '**/tests/*.tsx',
29+
// '**/tests/**/*.tsx',
30+
// ],
31+
// parserOptions: {
32+
// project: './tsconfig.json',
33+
// },
34+
// rules: {
35+
// '@typescript-eslint/prefer-readonly-parameter-types': [
36+
// 'warn',
37+
// { arraysAndTuplesOnly: true },
38+
// ],
39+
// },
40+
// },
41+
{
42+
files: ['src/tests/*.ts', 'src/**/tests/*.ts', 'src/**/tests/*.tsx'],
43+
rules: {
44+
'@typescript-eslint/no-unused-expressions': 'off',
45+
'no-lone-blocks': 'off',
46+
'no-sequences': 'off',
47+
},
48+
},
49+
],
1650
}

.github/workflows/main.yaml

Lines changed: 0 additions & 13 deletions
This file was deleted.

.github/workflows/size.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
name: size
2+
on: [pull_request]
3+
jobs:
4+
size:
5+
runs-on: ubuntu-latest
6+
env:
7+
CI_JOB_NUMBER: 1
8+
steps:
9+
- uses: actions/checkout@v1
10+
- uses: andresz1/size-limit-action@v1
11+
with:
12+
github_token: ${{ secrets.GITHUB_TOKEN }}
13+
build_script: build-only

.github/workflows/tests.yml

Lines changed: 51 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,53 @@ jobs:
2323
- name: Install deps
2424
run: npm ci
2525

26-
- name: Pack (including Prepare)
26+
- name: Build
27+
run: npm run build-ci
28+
29+
- name: Pack
2730
run: npm pack
28-
env:
29-
NODE_ENV: 'production' # this doesn't actually matter, so just set it to production
3031

3132
- uses: actions/upload-artifact@v2
3233
with:
3334
name: package
3435
path: reduxjs-toolkit*.tgz
3536

36-
test:
37+
test-dist:
38+
name: Test against dist
39+
needs: [build]
40+
runs-on: ubuntu-latest
41+
strategy:
42+
fail-fast: false
43+
matrix:
44+
node: ['14.x']
45+
steps:
46+
- name: Checkout repo
47+
uses: actions/checkout@v2
48+
49+
- name: Use node ${{ matrix.node }}
50+
uses: actions/setup-node@v1
51+
with:
52+
node-version: ${{ matrix.node }}
53+
54+
- uses: c-hive/gha-npm-cache@v1
55+
56+
- name: Install deps
57+
run: npm ci --ignore-scripts
58+
59+
- uses: actions/download-artifact@v2
60+
with:
61+
name: package
62+
63+
- name: Install build artifact
64+
run: |
65+
sed -i -e '/"name": "@reduxjs\/toolkit",/d' package.json
66+
npm i reduxjs-toolkit-*.tgz --ignore-scripts
67+
sed -i -e /@remap-prod-remove-line/d ./tsconfig.base.json ./jest.config.js ./src/tests/*.* ./src/query/tests/*.*
68+
69+
- name: Run tests, against dist
70+
run: npm test
71+
72+
test-types:
3773
name: Test Types with TypeScript ${{ matrix.ts }}
3874

3975
needs: [build]
@@ -42,7 +78,7 @@ jobs:
4278
fail-fast: false
4379
matrix:
4480
node: ['14.x']
45-
ts: ['3.8', '3.9', '4.0', '4.1', 'next']
81+
ts: ['3.9', '4.0', '4.1', '4.2', '4.3', 'next']
4682
steps:
4783
- name: Checkout repo
4884
uses: actions/checkout@v2
@@ -64,26 +100,19 @@ jobs:
64100
with:
65101
name: package
66102

67-
- name: Unpack build artifact to dist
68-
run: tar -xzvf reduxjs-toolkit-*.tgz --strip-components=1 package/dist
69-
70-
- name: Remap @redux/toolkit from src to dist
103+
- name: Install build artifact
71104
run: |
72-
sed -i -e 's|@reduxjs/toolkit": \["./src"\]|@reduxjs/toolkit": ["."]|' ./type-tests/files/tsconfig.json
105+
sed -i -e '/"name": "@reduxjs\/toolkit",/d' package.json
106+
npm i reduxjs-toolkit-*.tgz --ignore-scripts
107+
sed -i -e /@remap-prod-remove-line/d ./tsconfig.base.json ./jest.config.js ./src/tests/*.* ./src/query/tests/*.*
73108
74-
- name: Prefix `freeze` re-export for pre-3.7 TS versions with @ts-ignore
75-
if: ${{ matrix.ts < 3.7 }}
76-
run: |
77-
sed -i -e "/import .* freeze .* from 'immer'/s/^/\/\/ @ts-ignore\n/" dist/typings.d.ts
78-
sed -i -e "/ freeze,/s/^/ \/\/ @ts-ignore\n/" src/index.ts
109+
- name: "@ts-ignore stuff that didn't exist pre-4.1 in the tests"
110+
if: ${{ matrix.ts < 4.1 }}
111+
run: sed -i -e 's/@pre41-ts-ignore/@ts-ignore/' -e '/pre41-remove-start/,/pre41-remove-end/d' ./src/tests/*.* ./src/query/tests/*.ts*
79112

80-
- name: Use typings-tester for old TS versions
81-
if: ${{ matrix.ts < 3.9 }}
82-
run: |
83-
sed -i -e 's/"cd type-tests.*"/"npm run test type-tests"/' package.json
84-
sed -i -e 's/@ts-expect-error/typings:expect-error/' type-tests/files/*.typetest.ts
85-
sed -i -e 's/@ts-expect-error/@ts-ignore/' type-tests/files/*.ts
86-
mv type-tests/types.test.disabled.ts type-tests/types.test.ts
113+
- name: 'disable strictOptionalProperties'
114+
if: ${{ matrix.ts == 'next' }}
115+
run: sed -i -e 's|//\(.*strictOptionalProperties.*\)$|\1|' tsconfig.base.json
87116

88117
- name: Test types
89118
run: |

.gitignore

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
.DS_Store
22
*.log
33
node_modules
4-
dist
4+
# Dist and query are both build output folders
5+
dist*/
6+
!query/
7+
# But don't ignore the RTK Query source
8+
!src/query/
59
lib
610
es
711
yarn.lock
@@ -11,5 +15,10 @@ yarn.lock
1115
.vscode/
1216
temp/
1317
.tmp-projections
18+
build/
19+
.rts2*
1420

15-
.rts2*
21+
typesversions
22+
.cache
23+
.yarn
24+
.yarnrc

.size-limit.js

Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
const webpack = require('webpack')
2+
let { join } = require('path')
3+
4+
const suffixes = ['cjs.production.min.js', 'esm.js']
5+
6+
function withRtkPath(suffix) {
7+
return (config) => {
8+
config.plugins.push(
9+
new webpack.NormalModuleReplacementPlugin(
10+
/@reduxjs\/toolkit\/query\/react/,
11+
join(__dirname, `query/react`)
12+
),
13+
new webpack.NormalModuleReplacementPlugin(
14+
/@reduxjs\/toolkit\/query/,
15+
join(__dirname, `query`)
16+
),
17+
new webpack.NormalModuleReplacementPlugin(
18+
/@reduxjs\/toolkit/,
19+
join(__dirname)
20+
),
21+
new webpack.NormalModuleReplacementPlugin(
22+
/rtk-query-react.esm.js/,
23+
(r) => {
24+
const old = r.request
25+
r.request = r.request.replace(
26+
/rtk-query-react.esm.js$/,
27+
`rtk-query-react.${suffix}`
28+
)
29+
// console.log(old, '=>', r.request)
30+
}
31+
),
32+
new webpack.NormalModuleReplacementPlugin(/rtk-query.esm.js/, (r) => {
33+
const old = r.request
34+
r.request = r.request.replace(
35+
/rtk-query.esm.js$/,
36+
`rtk-query.${suffix}`
37+
)
38+
// console.log(old, '=>', r.request)
39+
}),
40+
new webpack.NormalModuleReplacementPlugin(
41+
/redux-toolkit.esm.js$/,
42+
(r) => {
43+
const old = r.request
44+
r.request = r.request.replace(
45+
/redux-toolkit.esm.js$/,
46+
`redux-toolkit.${suffix}`
47+
)
48+
// console.log(old, '=>', r.request)
49+
}
50+
)
51+
)
52+
if (suffix === 'cjs.production.min.js') {
53+
config.resolve.mainFields = ['main', 'module']
54+
}
55+
config.optimization.nodeEnv = 'production'
56+
return config
57+
}
58+
}
59+
60+
const ignoreAll = [
61+
'@reduxjs/toolkit',
62+
'@reduxjs/toolkit/query',
63+
'immer',
64+
'redux',
65+
'reselect',
66+
'redux-thunk',
67+
]
68+
69+
module.exports = [
70+
{
71+
name: `1. entry point: @reduxjs/toolkit`,
72+
path: 'dist/redux-toolkit.esm.js',
73+
},
74+
{
75+
name: `1. entry point: @reduxjs/toolkit/query`,
76+
path: 'dist/query/rtk-query.esm.js',
77+
},
78+
{
79+
name: `1. entry point: @reduxjs/toolkit/query/react`,
80+
path: 'dist/query/react/rtk-query-react.esm.js',
81+
},
82+
{
83+
name: `2. entry point: @reduxjs/toolkit (without dependencies)`,
84+
path: 'dist/redux-toolkit.esm.js',
85+
ignore: ignoreAll,
86+
},
87+
{
88+
name: `2. entry point: @reduxjs/toolkit/query (without dependencies)`,
89+
path: 'dist/query/rtk-query.esm.js',
90+
ignore: ignoreAll,
91+
},
92+
{
93+
name: `2. entry point: @reduxjs/toolkit/query/react (without dependencies)`,
94+
path: 'dist/query/react/rtk-query-react.esm.js',
95+
ignore: ignoreAll,
96+
},
97+
]
98+
.flatMap((e) =>
99+
suffixes.map((suffix) => ({
100+
...e,
101+
name: e.name + ` (${suffix})`,
102+
modifyWebpackConfig: withRtkPath(suffix),
103+
}))
104+
)
105+
.concat(
106+
...[
107+
{
108+
name: `3. createSlice`,
109+
import: { '@reduxjs/toolkit': '{ createSlice }' },
110+
},
111+
{
112+
name: `3. createEntityAdapter`,
113+
import: { '@reduxjs/toolkit': '{ createEntityAdapter }' },
114+
},
115+
{
116+
name: `3. configureStore`,
117+
import: { '@reduxjs/toolkit': '{ configureStore }' },
118+
},
119+
{
120+
name: `3. createApi`,
121+
import: { '@reduxjs/toolkit/query': '{ createApi }' },
122+
},
123+
{
124+
name: `3. createApi (react)`,
125+
import: { '@reduxjs/toolkit/query/react': '{ createApi }' },
126+
},
127+
{
128+
name: `3. fetchBaseQuery`,
129+
import: { '@reduxjs/toolkit/query': '{ fetchBaseQuery }' },
130+
},
131+
{
132+
name: `3. setupListeners`,
133+
import: { '@reduxjs/toolkit/query': '{ setupListeners }' },
134+
},
135+
{
136+
name: `3. ApiProvider`,
137+
import: { '@reduxjs/toolkit/query/react': '{ ApiProvider }' },
138+
},
139+
].map((e) => ({
140+
...e,
141+
name: e.name + ` (esm.js)`,
142+
modifyWebpackConfig: withRtkPath('esm.js'),
143+
}))
144+
)

api-extractor.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@
182182
/**
183183
* (REQUIRED) Whether to generate the .d.ts rollup file.
184184
*/
185-
"enabled": true,
185+
"enabled": false,
186186

187187
/**
188188
* Specifies the output path for a .d.ts rollup file to be generated without any trimming.

0 commit comments

Comments
 (0)