Skip to content

Commit a09a858

Browse files
committed
Fix the action logger running in production
The condition guarding the redux-logger middleware tested for the opposite of what it meant to test, so the logger was installed in production builds and left out during development. It relied on a build-time constant that Vite substitutes, so the check folded away and the middleware ended up unconditional in the shipped bundle. The check now uses Vite's own environment flags. Test runs are excluded as well, because Vite reports development mode there too and the logger would otherwise write into the output of every test that dispatches an action. This also drops the file's last reference to the Node process global, and with it an eslint exception. The redux-logger dependency still reaches the bundle even though nothing calls it now, because it is CommonJS and tree shaking cannot remove it. Dropping the dependency is separate work.
1 parent 9283212 commit a09a858

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

identifier/src/store.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,11 @@ const middlewares = [
88
thunkMiddleware
99
];
1010

11-
if (process.env.NODE_ENV !== 'development') { // eslint-disable-line no-undef
12-
middlewares.push(createLogger()); // must be last middleware in the chain.
11+
// The action logger is for interactive development only and must not be part of
12+
// a production build. Test mode is excluded as well, matching how
13+
// vite.config.js gates the checker plugin.
14+
if (import.meta.env.DEV && import.meta.env.MODE !== 'test') {
15+
middlewares.push(createLogger()); // Must be last middleware in the chain.
1316
}
1417

1518
const composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose;

0 commit comments

Comments
 (0)