title: required modules in a webpack bundle are undefined
body: <p>I am building a javascript library and using the require() method to require external modules into other modules. My problem is the modules I require are not defined. I can see all the modules are in the webpack output file but at run time the required modules return undefined.</p>
  
  <p>I did an experiment and moved the module which is getting required into another one at the top of the output file, this way the required module is loaded by the browser first. This fixed the problem.</p>
  
  <p>For example:</p>
  
  <pre><code>// main.js
  var moduleA = require('./module.a.js');
  
  var main = (function() {
      "use strict";
  
  
      return {
          moduleA: moduleA
      }
  })();
  
  exports.main = main;
  
  
  
  // module.a.js
  var moduleA = (function() {
      "use strict";
  
  
  
      return {
          myMethod: myMethod
      }
  })();
  
  exports.moduleA = moduleA;
  </code></pre>
  
  <p>currently my webpack.config.js defines that the entry file is main.js</p>
  
  <pre><code>    var path = require('path');
  var webpack = require('webpack');
  var libraryName = "myLib";
  
  module.exports = {
    entry: './src/modules/main.js',
    output: { 
      path: __dirname+"/build", 
      filename: libraryName+'.all.js',
      library: libraryName,
      libraryTarget: 'umd',
      umdNamedDefine: true
    },
    resolve: {
      root: [
          path.resolve('./src/')
      ]
    },
    module: {
      loaders: [
        // JS
        {
          test: /.js/,
          loader: "babel-loader",
          exclude: /node_modules/,
          query: {
            presets: ['es2015']
          }
        },
      ]
    }
  };
  </code></pre>
  
  <p>This is causing main.js to get loaded into the output file first, if manually reordering the modules in the output file so moduleA is read first before my main module, how can I fix this with webpack? My other webpack build has the entry file at the top of the output file, but it works fine. </p>