Skip to content

Commit 3b9722d

Browse files
committed
Manually dedupe all RTK imports in RTKQ core
1 parent 9a7803d commit 3b9722d

18 files changed

+60
-26
lines changed

packages/toolkit/src/index.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
// This must remain here so that the `mangleErrors.cjs` build script
2+
// does not have to import this into each source file it rewrites.
3+
import { formatProdErrorMessage } from './formatProdErrorMessage'
4+
15
export * from 'redux'
26
export {
37
produce as createNextState,
@@ -207,3 +211,5 @@ export { combineSlices } from './combineSlices'
207211
export type { WithSlice } from './combineSlices'
208212

209213
export type { ExtractDispatchExtensions as TSHelpersExtractDispatchExtensions } from './tsHelpers'
214+
215+
export { formatProdErrorMessage } from './formatProdErrorMessage'

packages/toolkit/src/query/core/buildMiddleware/cacheLifecycle.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { isAsyncThunkAction, isFulfilled } from '@reduxjs/toolkit'
1+
import { isAsyncThunkAction, isFulfilled } from '../rtkImports'
22
import type { UnknownAction } from 'redux'
33
import type { ThunkDispatch } from 'redux-thunk'
44
import type { BaseQueryFn, BaseQueryMeta } from '../../baseQueryTypes'

packages/toolkit/src/query/core/buildMiddleware/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import type {
44
ThunkDispatch,
55
UnknownAction,
66
} from '@reduxjs/toolkit'
7-
import { isAction, createAction } from '@reduxjs/toolkit'
7+
import { isAction, createAction } from '../rtkImports'
88

99
import type {
1010
EndpointDefinitions,

packages/toolkit/src/query/core/buildMiddleware/invalidationByTags.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { isAnyOf, isFulfilled, isRejectedWithValue } from '@reduxjs/toolkit'
1+
import { isAnyOf, isFulfilled, isRejectedWithValue } from '../rtkImports'
22

33
import type { FullTagDescription } from '../../endpointDefinitions'
44
import { calculateProvidedBy } from '../../endpointDefinitions'

packages/toolkit/src/query/core/buildMiddleware/queryLifecycle.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { isPending, isRejected, isFulfilled } from '@reduxjs/toolkit'
1+
import { isPending, isRejected, isFulfilled } from '../rtkImports'
22
import type {
33
BaseQueryError,
44
BaseQueryFn,

packages/toolkit/src/query/core/buildSelectors.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { createNextState, createSelector } from '@reduxjs/toolkit'
1+
import { createNextState, createSelector } from './rtkImports'
22
import type {
33
MutationSubState,
44
QuerySubState,

packages/toolkit/src/query/core/buildSlice.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {
88
isRejectedWithValue,
99
createNextState,
1010
prepareAutoBatched,
11-
} from '@reduxjs/toolkit'
11+
} from './rtkImports'
1212
import type {
1313
QuerySubstateIdentifier,
1414
QuerySubState,

packages/toolkit/src/query/core/buildThunks.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,12 @@ import {
3434
isPending,
3535
isRejected,
3636
isRejectedWithValue,
37-
} from '@reduxjs/toolkit'
37+
createAsyncThunk,
38+
SHOULD_AUTOBATCH,
39+
} from './rtkImports'
3840
import type { Patch } from 'immer'
3941
import { isDraftable, produceWithPatches } from 'immer'
4042
import type { ThunkAction, ThunkDispatch, AsyncThunk } from '@reduxjs/toolkit'
41-
import { createAsyncThunk, SHOULD_AUTOBATCH } from '@reduxjs/toolkit'
4243

4344
import { HandledError } from '../HandledError'
4445

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// This file exists to consolidate all of the imports from the `@reduxjs/toolkit` package.
2+
// ESBuild does not de-duplicate imports, so this file is used to ensure that each method
3+
// imported is only listed once, and there's only one mention of the `@reduxjs/toolkit` package.
4+
5+
export {
6+
createAction,
7+
createSlice,
8+
createSelector,
9+
createAsyncThunk,
10+
combineReducers,
11+
createNextState,
12+
isAnyOf,
13+
isAllOf,
14+
isAction,
15+
isPending,
16+
isRejected,
17+
isFulfilled,
18+
isRejectedWithValue,
19+
isAsyncThunkAction,
20+
prepareAutoBatched,
21+
SHOULD_AUTOBATCH,
22+
isPlainObject,
23+
nanoid,
24+
} from '@reduxjs/toolkit'

packages/toolkit/src/query/core/setupListeners.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import type {
22
ThunkDispatch,
33
ActionCreatorWithoutPayload, // Workaround for API-Extractor
44
} from '@reduxjs/toolkit'
5-
import { createAction } from '@reduxjs/toolkit'
5+
import { createAction } from './rtkImports'
66

77
export const onFocus = /* @__PURE__ */ createAction('__rtkq/focused')
88
export const onFocusLost = /* @__PURE__ */ createAction('__rtkq/unfocused')

0 commit comments

Comments
 (0)