title: Webpack require.ensure Error on --optimize--minimize
body: <p>I need to do code splitting and load some React component and other script on-demand, I simply do it like:</p>
  
  <pre><code>&lt;Route path="/journal" getComponent={function (nextState, cb) {
  
      require.ensure([], function (require) {
          cb(null, require("./components/Journal"));
      })
  
  }} /&gt;
  </code></pre>
  
  <p>In development, just run <code>webpack</code> it works just fine.</p>
  
  <p>But for production build, I run <code>webpack -p</code>, then I always get error:</p>
  
  <pre><code>Uncaught TypeError: Cannot read property 'call' of undefined
      at e (bootstrap a99e046…:50)
  </code></pre>
  
  <p>line 50 is:</p>
  
  <pre><code>// Execute the module function
      modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  </code></pre>
  
  <p>What could be the issue ?</p>
  
  <p>My webpack config:</p>
  
  <pre><code>var webpack = require('webpack');
  var merge = require('webpack-merge');
  var validate = require('webpack-validator');
  var parts = require('./webpack.parts');
  
  var common = {
    entry: {
      vendor: ['react', 'react-dom', 'lodash'],
    },
    output: {
      filename: "index.bundle.js",
      path: __dirname + '/public/js/',
      publicPath: __dirname + '/public/js/'
    },
    plugins: [
        new webpack.optimize.CommonsChunkPlugin({
          name: "vendor",
          minChunks: 3,
          filename: "vendor.bundle.js"
        })
    ]
  };
  
  var config;
  switch(process.env.npm_lifecycle_event) {
    case 'build':
      config = merge(common,
          {
              devtool: 'source-map',
              entry: {
                  app: [ __dirname + '/src/index.js']
              },
              module: {
                  loaders: [
                      {test: /\.js$/, exclude: /node_modules/, loaders: ["babel-loader"]}
                  ]
              }
          },
          parts.productionOptimize()
      );
      break;
    default:
        config = merge(
            common,
            {
                devtool: 'eval-source-map',
                entry: {
                    app: ['webpack-hot-middleware/client', __dirname + '/src/index.js']
                },
                module: {
                    loaders: [
                        {test: /\.js$/, exclude: /node_modules/, loaders: ["react-hot","babel-loader"]}
                    ]
                }
            },
            parts.devServer({
                host: process.env.HOST,
                port: process.env.PORT
            })
        );
  }
  
  module.exports = validate(config);
  </code></pre>
  
  <p><strong>webpack.parts.js</strong></p>
  
  <pre><code>var webpack = require('webpack');
  
  exports.devServer = function(options) {
      return {
          devServer: {
              historyApiFallback: true,
              inline: true,
              hot: true,
              stats: 'errors-only',
              host: options.host,
              port: options.port
          },
          plugins: [
              new webpack.HotModuleReplacementPlugin({
                  multistep: true
              })
          ]
      };
  }
  
  exports.productionOptimize = function () {
      return {
          plugins: [
              new webpack.DefinePlugin({
                  'process.env': {
                      NODE_ENV: JSON.stringify('production')
                  }
              }),
              new webpack.optimize.UglifyJsPlugin()
          ]
      }
  }
  </code></pre>