Skip to content

Commit cb0535d

Browse files
chore(build): move tsdx to esbuild (#957)
Co-authored-by: Mark Erikson <mark@isquaredsoftware.com>
1 parent 795af40 commit cb0535d

Some content is hidden

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

64 files changed

+20007
-6059
lines changed

.codesandbox/ci.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,6 @@
33
"vanilla",
44
"vanilla-ts",
55
"github/reduxjs/rtk-github-issues-example"
6-
]
6+
],
7+
"node": "14"
78
}

.github/workflows/tests.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ jobs:
77
runs-on: ubuntu-latest
88
strategy:
99
matrix:
10-
node: ['12.x']
10+
node: ['14.x']
1111

1212
steps:
1313
- name: Checkout repo
@@ -39,8 +39,8 @@ jobs:
3939
strategy:
4040
fail-fast: false
4141
matrix:
42-
node: ['12.x']
43-
ts: ['3.5', '3.6', '3.7', '3.8', '3.9', '4.0', '4.1', 'next']
42+
node: ['14.x']
43+
ts: ['3.8', '3.9', '4.0', '4.1', 'next']
4444
steps:
4545
- name: Checkout repo
4646
uses: actions/checkout@v2

.prettierrc.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
{
22
"semi": false,
3-
"singleQuote": true
3+
"singleQuote": true,
4+
"endOfLine": "auto"
45
}
6+

docs/tutorials/quick-start.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ Create a file named `src/app/store.js`. Import the `configureStore` API from Red
5151
import { configureStore } from '@reduxjs/toolkit'
5252

5353
export default configureStore({
54-
reducer: {}
54+
reducer: {},
5555
})
5656
```
5757

@@ -94,23 +94,23 @@ import { createSlice } from '@reduxjs/toolkit'
9494
export const counterSlice = createSlice({
9595
name: 'counter',
9696
initialState: {
97-
value: 0
97+
value: 0,
9898
},
9999
reducers: {
100-
increment: state => {
100+
increment: (state) => {
101101
// Redux Toolkit allows us to write "mutating" logic in reducers. It
102102
// doesn't actually mutate the state because it uses the Immer library,
103103
// which detects changes to a "draft state" and produces a brand new
104104
// immutable state based off those changes
105105
state.value += 1
106106
},
107-
decrement: state => {
107+
decrement: (state) => {
108108
state.value -= 1
109109
},
110110
incrementByAmount: (state, action) => {
111111
state.value += action.payload
112-
}
113-
}
112+
},
113+
},
114114
})
115115

116116
// Action creators are generated for each case reducer function
@@ -131,8 +131,8 @@ import counterReducer from '../features/counter/counterSlice'
131131
export default configureStore({
132132
reducer: {
133133
// highlight-next-line
134-
counter: counterReducer
135-
}
134+
counter: counterReducer,
135+
},
136136
})
137137
```
138138

@@ -147,7 +147,7 @@ import { decrement, increment } from './counterSlice'
147147
import styles from './Counter.module.css'
148148

149149
export function Counter() {
150-
const count = useSelector(state => state.counter.value)
150+
const count = useSelector((state) => state.counter.value)
151151
const dispatch = useDispatch()
152152

153153
return (

docs/tutorials/typescript.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ const store = configureStore({
5151
reducer: {
5252
posts: postsReducer,
5353
comments: commentsReducer,
54-
users: usersReducer
55-
}
54+
users: usersReducer,
55+
},
5656
})
5757

5858
// highlight-start
@@ -105,7 +105,7 @@ interface CounterState {
105105

106106
// Define the initial state using that type
107107
const initialState: CounterState = {
108-
value: 0
108+
value: 0,
109109
}
110110
// highlight-end
111111

@@ -114,19 +114,19 @@ export const counterSlice = createSlice({
114114
// `createSlice` will infer the state type from the `initialState` argument
115115
initialState,
116116
reducers: {
117-
increment: state => {
117+
increment: (state) => {
118118
state.value += 1
119119
},
120-
decrement: state => {
120+
decrement: (state) => {
121121
state.value -= 1
122122
},
123123
// highlight-start
124124
// Use the PayloadAction type to declare the contents of `action.payload`
125125
incrementByAmount: (state, action: PayloadAction<number>) => {
126126
// highlight-end
127127
state.value += action.payload
128-
}
129-
}
128+
},
129+
},
130130
})
131131

132132
export const { increment, decrement, incrementByAmount } = counterSlice.actions
@@ -144,7 +144,7 @@ In some cases, [TypeScript may unnecessarily tighten the type of the initial sta
144144
```ts
145145
// Workaround: cast state instead of declaring variable type
146146
const initialState = {
147-
value: 0
147+
value: 0,
148148
} as CounterState
149149
```
150150

@@ -163,7 +163,7 @@ import { decrement, increment } from './counterSlice'
163163
export function Counter() {
164164
// highlight-start
165165
// The `state` arg is correctly typed as `RootState` already
166-
const count = useAppSelector(state => state.counter.value)
166+
const count = useAppSelector((state) => state.counter.value)
167167
const dispatch = useAppDispatch()
168168
// highlight-end
169169

docs/usage/immer-reducers.md

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@ We can do this by hand using JavaScript's array / object spread operators, as we
4040
const obj = {
4141
a: {
4242
// To safely update obj.a.c, we have to copy each piece
43-
c: 3
43+
c: 3,
4444
},
45-
b: 2
45+
b: 2,
4646
}
4747

4848
const obj2 = {
@@ -53,8 +53,8 @@ const obj2 = {
5353
// copy obj.a
5454
...obj.a,
5555
// overwrite c
56-
c: 42
57-
}
56+
c: 42,
57+
},
5858
}
5959

6060
const arr = ['a', 'b']
@@ -107,7 +107,7 @@ So if we can't change the originals, how do we return an updated state?
107107
// ✅ This is safe, because we made a copy
108108
return {
109109
...state,
110-
value: 123
110+
value: 123,
111111
}
112112
```
113113

@@ -129,10 +129,10 @@ function handwrittenReducer(state, action) {
129129
...state.first.second,
130130
[action.someId]: {
131131
...state.first.second[action.someId],
132-
fourth: action.someValue
133-
}
134-
}
135-
}
132+
fourth: action.someValue,
133+
},
134+
},
135+
},
136136
}
137137
}
138138
```
@@ -153,15 +153,15 @@ import produce from 'immer'
153153
const baseState = [
154154
{
155155
todo: 'Learn typescript',
156-
done: true
156+
done: true,
157157
},
158158
{
159159
todo: 'Try immer',
160-
done: false
161-
}
160+
done: false,
161+
},
162162
]
163163

164-
const nextState = produce(baseState, draftState => {
164+
const nextState = produce(baseState, (draftState) => {
165165
// "mutate" the draft array
166166
draftState.push({ todo: 'Tweet about it' })
167167
// "mutate" the nested state
@@ -181,7 +181,7 @@ console.log(baseState[1] === nextState[1])
181181
Redux Toolkit's [`createReducer` API](../api/createReducer.mdx) uses Immer internally automatically. So, it's already safe to "mutate" state inside of any case reducer function that is passed to `createReducer`:
182182

183183
```js
184-
const todosReducer = createReducer([], builder => {
184+
const todosReducer = createReducer([], (builder) => {
185185
builder.addCase('todos/todoAdded', (state, action) => {
186186
// "mutate" the array by calling push()
187187
state.push(action.payload)
@@ -198,8 +198,8 @@ const todosSlice = createSlice({
198198
reducers: {
199199
todoAdded(state, action) {
200200
state.push(action.payload)
201-
}
202-
}
201+
},
202+
},
203203
})
204204
```
205205

@@ -214,8 +214,8 @@ const todosSlice = createSlice({
214214
name: 'todos',
215215
initialState: [],
216216
reducers: {
217-
todoAdded: addItemToArray
218-
}
217+
todoAdded: addItemToArray,
218+
},
219219
})
220220
```
221221

@@ -285,8 +285,8 @@ const todosSlice = createSlice({
285285
// ✅ SAFE: curly braces make this a function body and no return
286286
fixedReducer2: (state, action) => {
287287
state.push(action.payload)
288-
}
289-
}
288+
},
289+
},
290290
})
291291
```
292292

@@ -300,7 +300,7 @@ function objectCaseReducer1(state, action) {
300300
a,
301301
b,
302302
c,
303-
d
303+
d,
304304
}
305305
}
306306

@@ -352,8 +352,8 @@ const todosSlice = createSlice({
352352
correctResetTodosReducer(state, action) {
353353
// ✅ CORRECT: returns a new value to replace the old one
354354
return initialState
355-
}
356-
}
355+
},
356+
},
357357
})
358358
```
359359

@@ -377,8 +377,8 @@ const todosSlice = createSlice({
377377
console.log(state)
378378
// ✅ CORRECT: logs a plain JS copy of the current data
379379
console.log(current(state))
380-
}
381-
}
380+
},
381+
},
382382
})
383383
```
384384

@@ -400,21 +400,21 @@ const todosSlice = createSlice({
400400
initialState: [],
401401
reducers: {
402402
brokenTodoToggled(state, action) {
403-
const todo = state.find(todo => todo.id === action.payload)
403+
const todo = state.find((todo) => todo.id === action.payload)
404404
if (todo) {
405405
// ❌ ERROR: Immer can't track updates to a primitive value!
406406
let { completed } = todo
407407
completed = !completed
408408
}
409409
},
410410
fixedTodoToggled(state, action) {
411-
const todo = state.find(todo => todo.id === action.payload)
411+
const todo = state.find((todo) => todo.id === action.payload)
412412
if (todo) {
413413
// ✅ CORRECT: This object is still wrapped in a Proxy, so we can "mutate" it
414414
todo.completed = !todo.completed
415415
}
416-
}
417-
}
416+
},
417+
},
418418
})
419419
```
420420

@@ -442,8 +442,8 @@ const itemsSlice = createSlice({
442442
}
443443

444444
state[id].push(item)
445-
}
446-
}
445+
},
446+
},
447447
})
448448
```
449449

0 commit comments

Comments
 (0)