Skip to content

Conversation

@kaa4ever
Copy link

Added sideEffects flag to package.json to allow the tree shaking feature of webpack to totally disregard this module when imported.

A somewhat normal use case of redux-logger could be:

import { createStore, applyMiddleware } from 'redux';
import thunkMiddleware from 'redux-thunk';
import { createLogger } from './redux-logger';
import Reducer from './Reducer';

let store = createStore(Reducer, applyMiddleware(thunkMiddleware));

if (process.env.NODE_ENV !== 'production') {
   const loggerMiddleware = createLogger();
   store = createStore(Reducer, applyMiddleware(thunkMiddleware, loggerMiddleware));
}

When building for production, current Webpack behavior is to exclude anything inside the process.env.NODE_ENV !== 'production' conditional, but not remove the import { createLogger } from './redux-logger';. Since we are not using the logger in any way, it would be nice to totally disregard it from the production build. Adding the "sideEffects": false flag to package.json will achieve exactly that.

@codecov-io
Copy link

Codecov Report

Merging #313 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@          Coverage Diff          @@
##           master   #313   +/-   ##
=====================================
  Coverage      82%    82%           
=====================================
  Files           5      5           
  Lines         150    150           
=====================================
  Hits          123    123           
  Misses         27     27

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 3ca9f2c...99cdda4. Read the comment docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants