Skip to content

Commit cd52509

Browse files
authored
Merge branch 'master' into docs-update
2 parents 00224c4 + 40ad269 commit cd52509

File tree

208 files changed

+24769
-27197
lines changed

Some content is hidden

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

208 files changed

+24769
-27197
lines changed

.codesandbox/ci.json

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,17 @@
33
"vanilla",
44
"vanilla-ts",
55
"github/reduxjs/rtk-github-issues-example",
6-
"github/reduxjs/toolkit/examples/query/react/optimistic-updates"
6+
"/examples/query/react/basic",
7+
"/examples/query/react/advanced"
78
],
8-
"node": "14"
9-
}
9+
"node": "14",
10+
"buildCommand": "build:packages",
11+
"packages": [
12+
"packages/toolkit",
13+
"packages/rtk-query-graphql-request-base-query"
14+
],
15+
"publishDirectory": {
16+
"@reduxjs/toolkit": "packages/toolkit",
17+
"@rtk-query/graphql-request-base-query": "packages/rtk-query-graphql-request-base-query"
18+
}
19+
}

.eslintrc.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ module.exports = {
33
parser: '@typescript-eslint/parser',
44
rules: {
55
'jsx-a11y/href-no-hash': 'off',
6+
'react/react-in-jsx-scope': 'off',
67
// Taken care of by TypeScript's `noUnusedLocals` / `noUnusedParameters`
78
'no-unused-vars': 'off',
89
'@typescript-eslint/no-unused-vars': 'off',
@@ -39,7 +40,11 @@ module.exports = {
3940
// },
4041
// },
4142
{
42-
files: ['src/tests/*.ts', 'src/**/tests/*.ts', 'src/**/tests/*.tsx'],
43+
files: [
44+
'packages/toolkit/src/tests/*.ts',
45+
'packages/toolkit/src/**/tests/*.ts',
46+
'packages/toolkit/src/**/tests/*.tsx',
47+
],
4348
rules: {
4449
'@typescript-eslint/no-unused-expressions': 'off',
4550
'no-lone-blocks': 'off',

.github/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../packages/toolkit/README.md

.github/workflows/size.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,6 @@ jobs:
99
- uses: actions/checkout@v1
1010
- uses: andresz1/size-limit-action@v1
1111
with:
12+
directory: packages/toolkit
1213
github_token: ${{ secrets.GITHUB_TOKEN }}
1314
build_script: build-only

.github/workflows/tests.yml

Lines changed: 38 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
name: CI
22
on: [push, pull_request]
3+
defaults:
4+
run:
5+
working-directory: ./packages/toolkit
6+
37
jobs:
48
build:
59
name: Lint, Test, Build & Pack on Node ${{ matrix.node }}
@@ -18,21 +22,22 @@ jobs:
1822
with:
1923
node-version: ${{ matrix.node }}
2024

21-
- uses: c-hive/gha-npm-cache@v1
25+
- uses: actions/cache@v2
26+
with:
27+
path: .yarn/cache
28+
key: yarn-${{ hashFiles('yarn.lock') }}
29+
restore-keys: yarn-
2230

2331
- name: Install deps
24-
run: npm ci
25-
26-
- name: Build
27-
run: npm run build-ci
32+
run: yarn install
2833

2934
- name: Pack
30-
run: npm pack
35+
run: yarn pack
3136

3237
- uses: actions/upload-artifact@v2
3338
with:
3439
name: package
35-
path: reduxjs-toolkit*.tgz
40+
path: packages/toolkit/package.tgz
3641

3742
test-dist:
3843
name: Test against dist
@@ -51,23 +56,29 @@ jobs:
5156
with:
5257
node-version: ${{ matrix.node }}
5358

54-
- uses: c-hive/gha-npm-cache@v1
59+
- uses: actions/cache@v2
60+
with:
61+
path: .yarn/cache
62+
key: yarn-${{ hashFiles('yarn.lock') }}
63+
restore-keys: yarn-
5564

5665
- name: Install deps
57-
run: npm ci --ignore-scripts
66+
run: yarn install
5867

5968
- uses: actions/download-artifact@v2
6069
with:
6170
name: package
71+
path: packages/toolkit
72+
73+
- run: ls -lah
6274

6375
- 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/*.*
76+
run: yarn workspace @reduxjs/toolkit add $(pwd)/package.tgz
77+
78+
- run: sed -i -e /@remap-prod-remove-line/d ./tsconfig.base.json ./jest.config.js ./src/tests/*.* ./src/query/tests/*.*
6879

6980
- name: Run tests, against dist
70-
run: npm test
81+
run: yarn test
7182

7283
test-types:
7384
name: Test Types with TypeScript ${{ matrix.ts }}
@@ -88,33 +99,33 @@ jobs:
8899
with:
89100
node-version: ${{ matrix.node }}
90101

91-
- uses: c-hive/gha-npm-cache@v1
102+
- uses: actions/cache@v2
103+
with:
104+
path: .yarn/cache
105+
key: yarn-${{ hashFiles('yarn.lock') }}
106+
restore-keys: yarn-
92107

93108
- name: Install deps
94-
run: npm ci --ignore-scripts
109+
run: yarn install
95110

96111
- name: Install TypeScript ${{ matrix.ts }}
97-
run: npm install typescript@${{ matrix.ts }} --ignore-scripts
112+
run: yarn add typescript@${{ matrix.ts }}
98113

99114
- uses: actions/download-artifact@v2
100115
with:
101116
name: package
117+
path: packages/toolkit
102118

103119
- name: Install build artifact
104-
run: |
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/*.*
120+
run: yarn add ./package.tgz
121+
122+
- run: sed -i -e /@remap-prod-remove-line/d ./tsconfig.base.json ./jest.config.js ./src/tests/*.* ./src/query/tests/*.*
108123

109124
- name: "@ts-ignore stuff that didn't exist pre-4.1 in the tests"
110125
if: ${{ matrix.ts < 4.1 }}
111126
run: sed -i -e 's/@pre41-ts-ignore/@ts-ignore/' -e '/pre41-remove-start/,/pre41-remove-end/d' ./src/tests/*.* ./src/query/tests/*.ts*
112127

113-
- name: 'disable strictOptionalProperties'
114-
if: ${{ matrix.ts == 'next' }}
115-
run: sed -i -e 's|//\(.*strictOptionalProperties.*\)$|\1|' tsconfig.base.json
116-
117128
- name: Test types
118129
run: |
119-
./node_modules/.bin/tsc --version
120-
npm run type-tests
130+
yarn tsc --version
131+
yarn type-tests

.gitignore

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,9 @@
33
node_modules
44
# Dist and query are both build output folders
55
dist*/
6-
!query/
76
# But don't ignore the RTK Query source
8-
!src/query/
97
lib
108
es
11-
yarn.lock
129

1310

1411
.idea/
@@ -20,5 +17,16 @@ build/
2017

2118
typesversions
2219
.cache
23-
.yarn
2420
.yarnrc
21+
.yarn/*
22+
!.yarn/patches
23+
!.yarn/releases
24+
!.yarn/plugins
25+
!.yarn/sdks
26+
!.yarn/versions
27+
.pnp.*
28+
*.tgz
29+
30+
.yalc
31+
yalc.lock
32+
yalc.sig
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
diff --git a/config/webpack.config.js b/config/webpack.config.js
2+
index ba8fd0b9b56a073c6f6173feb9e3154290ceeda2..bf316c8df3b5dd9e862b3b4f02019d449ee06516 100644
3+
--- a/config/webpack.config.js
4+
+++ b/config/webpack.config.js
5+
@@ -24,7 +24,6 @@ const ManifestPlugin = require('webpack-manifest-plugin');
6+
const InterpolateHtmlPlugin = require('react-dev-utils/InterpolateHtmlPlugin');
7+
const WorkboxWebpackPlugin = require('workbox-webpack-plugin');
8+
const WatchMissingNodeModulesPlugin = require('react-dev-utils/WatchMissingNodeModulesPlugin');
9+
-const ModuleScopePlugin = require('react-dev-utils/ModuleScopePlugin');
10+
const getCSSModuleLocalIdent = require('react-dev-utils/getCSSModuleLocalIdent');
11+
const ESLintPlugin = require('eslint-webpack-plugin');
12+
const paths = require('./paths');
13+
@@ -349,15 +348,6 @@ module.exports = function (webpackEnv) {
14+
// Adds support for installing with Plug'n'Play, leading to faster installs and adding
15+
// guards against forgotten dependencies and such.
16+
PnpWebpackPlugin,
17+
- // Prevents users from importing files from outside of src/ (or node_modules/).
18+
- // This often causes confusion because we only process files within src/ with babel.
19+
- // To fix this, we prevent you from importing files out of src/ -- if you'd like to,
20+
- // please link the files into your node_modules/ and let module-resolution kick in.
21+
- // Make sure your source files are compiled, as they will not be processed in any way.
22+
- new ModuleScopePlugin(paths.appSrc, [
23+
- paths.appPackageJson,
24+
- reactRefreshOverlayEntry,
25+
- ]),
26+
],
27+
},
28+
resolveLoader: {
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
module.exports = {
2+
name: `@yarnpkg/plugin-compat`,
3+
factory: (require) => {
4+
// we are not using PNP and want to use `typescript@next` in CI without hassle
5+
// dummy implementation to override the built-in version of this plugin
6+
// can be dropped once we switch to yarn 3
7+
return {}
8+
},
9+
}

.yarn/plugins/@yarnpkg/plugin-workspace-tools.cjs

Lines changed: 29 additions & 0 deletions
Large diffs are not rendered by default.

.yarn/releases/yarn-berry.cjs

Lines changed: 55 additions & 0 deletions
Large diffs are not rendered by default.

.yarnrc.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
nodeLinker: node-modules
2+
3+
plugins:
4+
- path: .yarn/plugins/@yarnpkg/plugin-workspace-tools.cjs
5+
spec: '@yarnpkg/plugin-workspace-tools'
6+
- path: .yarn/plugins/@yarnpkg/plugin-compat.cjs
7+
spec: '@yarnpkg/plugin-compat'
8+
9+
yarnPath: .yarn/releases/yarn-berry.cjs

CONTRIBUTING.md

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -8,49 +8,48 @@ Before opening an issue, please search the [issue tracker](https://github.com/re
88

99
Please ask any general and implementation specific questions on [Stack Overflow with a Redux Toolkit tag](http://stackoverflow.com/questions/tagged/redux-toolkit?sort=votes&pageSize=50) for support.
1010

11-
## Development
11+
## New Features
1212

13-
Visit the [Issue tracker](https://github.com/reduxjs/redux-toolkit/issues) to find a list of open issues that need attention.
13+
Please open an issue with a proposal for a new feature or refactoring before starting on the work. We don't want you to waste your efforts on a pull request that we won't want to accept.
1414

15-
Fork, then clone the repo:
15+
## Getting started
1616

17-
```
18-
git clone https://github.com/your-username/redux-toolkit.git
19-
```
17+
Visit the [Issue tracker](https://github.com/reduxjs/redux-toolkit/issues) to find a list of open issues that need attention.
2018

21-
### Building
19+
### Fork the repository
2220

23-
Running the `build` task will create both a CommonJS module-per-module build and a UMD build.
21+
Please use the GitHub UI to [fork this repository](https://github.com/reduxjs/redux-toolkit) (_read more about [Forking a repository](https://docs.github.com/en/github/getting-started-with-github/fork-a-repo)_). Redux Toolkit has forked builds enabled in the CI, so you will see the build status of your fork's branch.
2422

25-
```
26-
npm run build
23+
### Install
24+
25+
```bash
26+
$ cd redux-toolkit
27+
$ yarn
2728
```
2829

29-
### Testing and Linting
30+
### Tests
3031

31-
To run the tests:
32+
You can run tests for all packages with:
3233

3334
```
34-
npm run test
35+
yarn test
3536
```
3637

3738
To continuously watch and run tests, run the following:
3839

3940
```
40-
npm test -- --watch
41+
yarn test --watch
4142
```
4243

43-
To perform linting with `eslint`, run the following:
44+
### Build
45+
46+
You can build the packages with the following command:
4447

4548
```
46-
npm run lint
49+
yarn build
4750
```
4851

49-
### New Features
50-
51-
Please open an issue with a proposal for a new feature or refactoring before starting on the work. We don't want you to waste your efforts on a pull request that we won't want to accept.
52-
53-
## Submitting Changes
52+
## Git workflow / Submitting Changes
5453

5554
- Open a new issue in the [Issue tracker](https://github.com/reduxjs/redux-toolkit/issues).
5655
- Fork the repo.

docs/api/createSlice.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ If you need to customize the creation of the payload value of an action creator
107107

108108
```ts
109109
import { createSlice, PayloadAction } from '@reduxjs/toolkit'
110-
import nanoid from 'nanoid'
110+
import { nanoid } from 'nanoid'
111111
112112
interface Item {
113113
id: string

docs/api/otherExports.mdx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,10 @@ const todosReducer = createReducer(initialState, (builder) => {
8484

8585
[The `isDraft` function](https://immerjs.github.io/immer/original) from the [`immer` library](https://immerjs.github.io/immer/), which checks to see if a given value is a Proxy-wrapped "draft" state.
8686

87+
### `freeze`
88+
89+
[The `freeze` function](https://immerjs.github.io/immer/api) from the [`immer` library](https://immerjs.github.io/immer/), which [freezes](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/freeze) draftable objects.
90+
8791
### `combineReducers`
8892

8993
Redux's [`combineReducers`](https://redux.js.org/api/combinereducers), re-exported for convenience. While `configureStore` calls this internally, you may wish to call it yourself to compose multiple levels of slice reducers.

0 commit comments

Comments
 (0)