Skip to content

Commit b79043b

Browse files
committed
Merge branch 'feature/v1.6-integration' into feature/remove-alpha.3-deprecations
# Conflicts: # src/query/createApi.ts # src/query/endpointDefinitions.ts
2 parents a1b1011 + ada1f4b commit b79043b

File tree

391 files changed

+276177
-18218
lines changed

Some content is hidden

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

391 files changed

+276177
-18218
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: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,18 @@ module.exports = {
1313
'@typescript-eslint/no-redeclare': 'off',
1414
'no-use-before-define': 'off',
1515
'@typescript-eslint/no-use-before-define': ['error', { functions: false }],
16+
'@typescript-eslint/consistent-type-imports': [
17+
'error',
18+
{ prefer: 'type-imports', disallowTypeAnnotations: false },
19+
],
1620
},
1721
overrides: [
1822
{
1923
files: ['src/tests/*.ts', 'src/**/tests/*.ts', 'src/**/tests/*.tsx'],
2024
rules: {
2125
'@typescript-eslint/no-unused-expressions': 'off',
2226
'no-lone-blocks': 'off',
27+
'no-sequences': 'off',
2328
},
2429
},
2530
],

.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: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,11 @@ 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:

.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+
)

docs/api/configureStore.mdx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ sidebar_label: configureStore
55
hide_title: true
66
---
77

8+
 
9+
810
# `configureStore`
911

1012
A friendly abstraction over the standard Redux `createStore` function that adds good defaults

docs/api/createAction.mdx

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ sidebar_label: createAction
55
hide_title: true
66
---
77

8+
 
9+
810
# `createAction`
911

1012
A helper function for defining a Redux [action](https://redux.js.org/basics/actions) type and creator.
@@ -21,7 +23,7 @@ const INCREMENT = 'counter/increment'
2123
function increment(amount: number) {
2224
return {
2325
type: INCREMENT,
24-
payload: amount
26+
payload: amount,
2527
}
2628
}
2729

@@ -63,8 +65,8 @@ const addTodo = createAction('todos/add', function prepare(text: string) {
6365
payload: {
6466
text,
6567
id: nanoid(),
66-
createdAt: new Date().toISOString()
67-
}
68+
createdAt: new Date().toISOString(),
69+
},
6870
}
6971
})
7072

@@ -95,7 +97,7 @@ import { createAction, createReducer } from '@reduxjs/toolkit'
9597
const increment = createAction<number>('counter/increment')
9698
const decrement = createAction<number>('counter/decrement')
9799

98-
const counterReducer = createReducer(0, builder => {
100+
const counterReducer = createReducer(0, (builder) => {
99101
builder.addCase(increment, (state, action) => state + action.payload)
100102
builder.addCase(decrement, (state, action) => state - action.payload)
101103
})
@@ -133,7 +135,7 @@ const counterReducer = createReducer(0, {
133135
[increment]: (state, action) => state + action.payload,
134136

135137
// You would need to use the action type explicitly instead.
136-
[INCREMENT]: (state, action) => state + action.payload
138+
[INCREMENT]: (state, action) => state + action.payload,
137139
})
138140
```
139141
@@ -178,7 +180,7 @@ const increment = createAction<number>('INCREMENT')
178180
export const epic = (actions$: Observable<Action>) =>
179181
actions$.pipe(
180182
filter(increment.match),
181-
map(action => {
183+
map((action) => {
182184
// action.payload can be safely used as number here (and will also be correctly inferred by TypeScript)
183185
// ...
184186
})

0 commit comments

Comments
 (0)