title: Does Webpack tree shaking with dead code elimination work on node_modules?
body: <p>Considering this <code>Webpack 3.8.1</code> config.</p>
  
  <pre><code>// common
  module.exports = {
          context: path.resolve(__dirname, './src'),
          entry: [
              'whatwg-fetch',
              './index'
          ],
          output: {
              path: path.resolve(__dirname, 'build/assets'),
              publicPath: '/assets/',
              filename: 'main.js'
          },
          plugins: [
              new CleanWebpackPlugin(['build']),
          ],
          module: {
              rules: [{
                  test: /\.js$/,
                  exclude: /node_modules/,
                  use: {
                      loader: 'babel-loader',
                  }
              }, {
                  test: /\.(scss|css)$/,
                  use: [{
                      loader: 'style-loader'
                  }, {
                      loader: 'css-loader'
                  }, {
                      loader: 'sass-loader'
                  }],
              }, {
                  test: /\.(png|jpg|gif|woff2|woff)$/,
                  use: [
                      {
                          loader: 'url-loader',
                          options: {
                              limit: 8192
                          }
                      }
                  ]
              }]
          }
      };
  
  //prod
  module.exports = merge(common, {
      plugins: [
          new webpack.DefinePlugin({
              'process.env.NODE_ENV': JSON.stringify('production')
          }),
          new UglifyJSPlugin()
      ],
      devtool: 'none'
  });
  </code></pre>
  
  <p>and this <code>Babel 6.26.0</code> config</p>
  
  <pre><code>{
    "presets": [
      [
        "env",
        {
          "modules": false,
          "targets": {
            "browsers": [
              "&gt;1%"
            ]
          }
        }
      ], [
        "react"
      ]
    ],
    "plugins": [
      "transform-class-properties",
      "transform-export-extensions",
      "transform-object-rest-spread",
      "react-hot-loader/babel"
    ]
  }
  </code></pre>
  
  <p>I was expecting that tree shaking alongside with dead code elimination of <code>UglifyJS</code> should work in a way that enables me to write named imports from <code>index.es.js</code> modules, for example <code>Material-UI-Icons</code> and unused ones get removed from the bundle.</p>
  
  <pre><code>import {Menu} from 'material-ui-icons';
  </code></pre>
  
  <p>This library does indeed reexport ES6 modules defined in package.json as <code>"module": "index.es.js"</code>.</p>
  
  <p>Yet my bundle size increased by 0.5MB after importing single icon. When I changed it to</p>
  
  <pre><code>import Menu from 'material-ui-icons/Menu;
  </code></pre>
  
  <p>bundle size got reduced again with only this icon imported.</p>
  
  <p>Is there something wrong in my configuration, or do I missunderstand how tree shaking works and does not apply to this scenario?</p>