title: Disable tree shaking in Webpack 4
body: <p>Is there a config option to disable unused module detection in Webpack 4?</p>
  
  <p>We recently switched from <code>lodash</code> to <code>lodash-es</code> to support tree shaking. It works great and the bundles are much smaller, but now our build takes about twice as long (up from 3 minutes to 6 minutes).</p>
  
  <p>Would be great to disable it on dev to speed up the build, since bundle size doesn't matter there.</p>
  
  <p>I found this undocumented config option but I'm not sure how it would apply <a href="https://github.com/webpack/webpack/blob/master/lib/WebpackOptionsDefaulter.js#L207" rel="noreferrer">https://github.com/webpack/webpack/blob/master/lib/WebpackOptionsDefaulter.js#L207</a>. Obviously UglifyJS is not running in dev so i'm assuming all of the slowdown comes from Webpack doing the work to mark which modules are unused.</p>
  
  <p>I was thinking you could do something like aliasing <code>lodash-es</code> to <code>lodash</code> only on dev, but that's super hacky, and anyway Lodash doesn't work with the <code>import * as _</code> syntax that <code>lodash-es</code> requires for tree shaking</p>
  
  <p>I'm assuming this is the plugin that does the work of marking imports as unused, but since it's enabled by default I don't know how to disable it or remove it from the plugins array <a href="https://github.com/webpack/webpack/blob/next/lib/optimize/SideEffectsFlagPlugin.js#L1" rel="noreferrer">https://github.com/webpack/webpack/blob/next/lib/optimize/SideEffectsFlagPlugin.js#L1</a></p>
  
  <p>It seems strange you can't just set <code>treeShaking: false</code> or something in the config. <a href="https://webpack.js.org/guides/tree-shaking/" rel="noreferrer">https://webpack.js.org/guides/tree-shaking/</a> doesn't mention anything.</p>
  
  <p>We are already setting <code>mode</code> to <code>development</code> or <code>production</code> based on the build environment, but we see these slower build times even on development. this would suggest that <code>mode: development</code> does not disable the unused module detection.</p>