@@ -32,8 +32,6 @@ import type { Tuple } from './utils'
3232import type { GetDefaultEnhancers } from './getDefaultEnhancers'
3333import { buildGetDefaultEnhancers } from './getDefaultEnhancers'
3434
35- const IS_PRODUCTION = process . env . NODE_ENV === 'production'
36-
3735/**
3836 * Options for `configureStore()`.
3937 *
@@ -146,15 +144,22 @@ export function configureStore<
146144 )
147145 }
148146
149- if ( ! IS_PRODUCTION && middleware && typeof middleware !== 'function' ) {
147+ if (
148+ process . env . NODE_ENV !== 'production' &&
149+ middleware &&
150+ typeof middleware !== 'function'
151+ ) {
150152 throw new Error ( '`middleware` field must be a callback' )
151153 }
152154
153155 let finalMiddleware : Tuple < Middlewares < S > >
154156 if ( typeof middleware === 'function' ) {
155157 finalMiddleware = middleware ( getDefaultMiddleware )
156158
157- if ( ! IS_PRODUCTION && ! Array . isArray ( finalMiddleware ) ) {
159+ if (
160+ process . env . NODE_ENV !== 'production' &&
161+ ! Array . isArray ( finalMiddleware )
162+ ) {
158163 throw new Error (
159164 'when using a middleware builder function, an array of middleware must be returned' ,
160165 )
@@ -163,7 +168,7 @@ export function configureStore<
163168 finalMiddleware = getDefaultMiddleware ( )
164169 }
165170 if (
166- ! IS_PRODUCTION &&
171+ process . env . NODE_ENV !== 'production' &&
167172 finalMiddleware . some ( ( item : any ) => typeof item !== 'function' )
168173 ) {
169174 throw new Error (
@@ -176,7 +181,7 @@ export function configureStore<
176181 if ( devTools ) {
177182 finalCompose = composeWithDevTools ( {
178183 // Enable capture of stack traces for dispatched Redux actions
179- trace : ! IS_PRODUCTION ,
184+ trace : process . env . NODE_ENV !== 'production' ,
180185 ...( typeof devTools === 'object' && devTools ) ,
181186 } )
182187 }
@@ -185,7 +190,11 @@ export function configureStore<
185190
186191 const getDefaultEnhancers = buildGetDefaultEnhancers < M > ( middlewareEnhancer )
187192
188- if ( ! IS_PRODUCTION && enhancers && typeof enhancers !== 'function' ) {
193+ if (
194+ process . env . NODE_ENV !== 'production' &&
195+ enhancers &&
196+ typeof enhancers !== 'function'
197+ ) {
189198 throw new Error ( '`enhancers` field must be a callback' )
190199 }
191200
@@ -194,19 +203,19 @@ export function configureStore<
194203 ? enhancers ( getDefaultEnhancers )
195204 : getDefaultEnhancers ( )
196205
197- if ( ! IS_PRODUCTION && ! Array . isArray ( storeEnhancers ) ) {
206+ if ( process . env . NODE_ENV !== 'production' && ! Array . isArray ( storeEnhancers ) ) {
198207 throw new Error ( '`enhancers` callback must return an array' )
199208 }
200209 if (
201- ! IS_PRODUCTION &&
210+ process . env . NODE_ENV !== 'production' &&
202211 storeEnhancers . some ( ( item : any ) => typeof item !== 'function' )
203212 ) {
204213 throw new Error (
205214 'each enhancer provided to configureStore must be a function' ,
206215 )
207216 }
208217 if (
209- ! IS_PRODUCTION &&
218+ process . env . NODE_ENV !== 'production' &&
210219 finalMiddleware . length &&
211220 ! storeEnhancers . includes ( middlewareEnhancer )
212221 ) {
0 commit comments