I’m encountering a TypeError: l is not a function error in my Redux middleware when I build my project for production. This error does not occur when running the development server.
heres my redux middleware setup
import { compose, createStore, applyMiddleware } from 'redux';
import logger from 'redux-logger';
import { rootReducer } from './root-reducer';
import storage from 'redux-persist/lib/storage';
import { persistStore, persistReducer } from 'redux-persist';
import thunk from 'redux-thunk';
const loggerMiddleware = store => next => action => {
if (!action.type) {
return next(action);
}
console.log('type: ', action.type);
console.log('payload: ', action.payload);
console.log('currentState: ', store.getState());
next(action);
console.log('NextState: ', store.getState());
};
const persistConfig = {
key: 'root',
whitelist: ['cart'],
storage,
};
const persistedReducer = persistReducer(persistConfig, rootReducer);
const middleWares = [
process.env.NODE_ENV !== 'production' && loggerMiddleware,
thunk,
].filter(Boolean);
const composedEnhancers = compose(applyMiddleware(...middleWares));
export const store = createStore(persistedReducer, undefined, composedEnhancers);
export const persistor = persistStore(store);
error message
TypeError: l is not a function
at index-BQTYK8ps.js:3232:4031
at Array.map (<anonymous>)
at index-BQTYK8ps.js:3232:4024
at Zm (index-BQTYK8ps.js:3232:2202)
at index-BQTYK8ps.js:3232:13786
i did in development that all middleware are function and they are function in development but in production i dont get any console.log; i dont know why
its vite project with javascript + swc
also heres link to my github repo as its my practice project
Github
all the code related to redux-thunk and middleware are in src/store
it will be great to know reason why this issue exists, thank you for the support