@@ -32,8 +32,6 @@ import type { Tuple } from './utils'
32
32
import type { GetDefaultEnhancers } from './getDefaultEnhancers'
33
33
import { buildGetDefaultEnhancers } from './getDefaultEnhancers'
34
34
35
- const IS_PRODUCTION = process . env . NODE_ENV === 'production'
36
-
37
35
/**
38
36
* Options for `configureStore()`.
39
37
*
@@ -146,15 +144,22 @@ export function configureStore<
146
144
)
147
145
}
148
146
149
- if ( ! IS_PRODUCTION && middleware && typeof middleware !== 'function' ) {
147
+ if (
148
+ process . env . NODE_ENV !== 'production' &&
149
+ middleware &&
150
+ typeof middleware !== 'function'
151
+ ) {
150
152
throw new Error ( '`middleware` field must be a callback' )
151
153
}
152
154
153
155
let finalMiddleware : Tuple < Middlewares < S > >
154
156
if ( typeof middleware === 'function' ) {
155
157
finalMiddleware = middleware ( getDefaultMiddleware )
156
158
157
- if ( ! IS_PRODUCTION && ! Array . isArray ( finalMiddleware ) ) {
159
+ if (
160
+ process . env . NODE_ENV !== 'production' &&
161
+ ! Array . isArray ( finalMiddleware )
162
+ ) {
158
163
throw new Error (
159
164
'when using a middleware builder function, an array of middleware must be returned' ,
160
165
)
@@ -163,7 +168,7 @@ export function configureStore<
163
168
finalMiddleware = getDefaultMiddleware ( )
164
169
}
165
170
if (
166
- ! IS_PRODUCTION &&
171
+ process . env . NODE_ENV !== 'production' &&
167
172
finalMiddleware . some ( ( item : any ) => typeof item !== 'function' )
168
173
) {
169
174
throw new Error (
@@ -176,7 +181,7 @@ export function configureStore<
176
181
if ( devTools ) {
177
182
finalCompose = composeWithDevTools ( {
178
183
// Enable capture of stack traces for dispatched Redux actions
179
- trace : ! IS_PRODUCTION ,
184
+ trace : process . env . NODE_ENV !== 'production' ,
180
185
...( typeof devTools === 'object' && devTools ) ,
181
186
} )
182
187
}
@@ -185,7 +190,11 @@ export function configureStore<
185
190
186
191
const getDefaultEnhancers = buildGetDefaultEnhancers < M > ( middlewareEnhancer )
187
192
188
- if ( ! IS_PRODUCTION && enhancers && typeof enhancers !== 'function' ) {
193
+ if (
194
+ process . env . NODE_ENV !== 'production' &&
195
+ enhancers &&
196
+ typeof enhancers !== 'function'
197
+ ) {
189
198
throw new Error ( '`enhancers` field must be a callback' )
190
199
}
191
200
@@ -194,19 +203,19 @@ export function configureStore<
194
203
? enhancers ( getDefaultEnhancers )
195
204
: getDefaultEnhancers ( )
196
205
197
- if ( ! IS_PRODUCTION && ! Array . isArray ( storeEnhancers ) ) {
206
+ if ( process . env . NODE_ENV !== 'production' && ! Array . isArray ( storeEnhancers ) ) {
198
207
throw new Error ( '`enhancers` callback must return an array' )
199
208
}
200
209
if (
201
- ! IS_PRODUCTION &&
210
+ process . env . NODE_ENV !== 'production' &&
202
211
storeEnhancers . some ( ( item : any ) => typeof item !== 'function' )
203
212
) {
204
213
throw new Error (
205
214
'each enhancer provided to configureStore must be a function' ,
206
215
)
207
216
}
208
217
if (
209
- ! IS_PRODUCTION &&
218
+ process . env . NODE_ENV !== 'production' &&
210
219
finalMiddleware . length &&
211
220
! storeEnhancers . includes ( middlewareEnhancer )
212
221
) {
0 commit comments