Skip to content

Conversation

@Tvrqvoise
Copy link

Adding "sideEffects": false flags to webpack that this package is safe to remove if no functions were imported from it. This means that if I do something along the lines of:

import { createLogger } from 'redux-logger'

/* later */

if (process.env.NODE_ENV === 'development') {
  middleware.push(createLogger({ collapsed: true }))
}

Then the package will not be included in my bundle when process.env.NODE_ENV !== 'development'. Currently, the variable gets removed from local scope, but Webpack cannot optimize the harmony import since it assumes it has side effects, so it remains in bundle.

Adding `"sideEffects": false` flags to webpack that this package is safe to remove if no functions were imported from it.  This means that if I do something along the lines of:

```js
import { createLogger } from 'redux-logger'

/* later */

if (process.env.NODE_ENV === 'development') {
  middleware.push(createLogger({ collapsed: true }))
}
```

Then the package will not be included in my bundle when `process.env.NODE_ENV !== 'development'`.  Currently, the variable gets removed from local scope, but Webpack cannot optimize the harmony import since it assumes it has side effects, so it remains in bundle.
@Tvrqvoise
Copy link
Author

This is literally a duplicate of #313. I swear I checked, honest, but I didn't see that originally. Whoops! Closing this.

@Tvrqvoise Tvrqvoise closed this Dec 3, 2018
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.

1 participant