title: WebPack Dynamically load bundle on demand
body: <p>We are using webpack 1.14.0 to bundle our application. Currently we are looking for an approach where we need to load a  bundle on demand dynamically.  </p>
  
  <p>Our requirement is to load readme.md and example.md files dynamically from bundle.
  I am trying using <strong>require.ensure</strong>, below is the sample that I am trying</p>
  
  <pre><code>//app.js entry point for webpack config
  require("./login"); //sample login file just contains console log stmnt.
  
  window.clickButton = function () {
      require.ensure(['./ensureTest'], function (require) {
  
         var a = require('./ensureTest');
  
      });
  
  }
  console.log("App Loaded"); 
  
  //ensureTest.js   testing to load this module dynamically on demand
  define([], function(){
      console.log("Loaded ensure runtime");
  });
  </code></pre>
  
  <p>Below is my webpack config</p>
  
  <pre><code>module.exports = {
      entry: ["./app.js"],
      output: {
          filename: "bundle.js"
      },
      module:{
          loaders:[
              {
                  test:/\.es6$/,
                  exclude : "node_modules",
                  loader:"babel-loader"
              }
          ]
      },
      resolve:{
          extensions :['', '.es6','.js']
      }
  }
  </code></pre>
  
  <p>When I run WebPack command I am able to see bundle.js and 1.bundle.js file created.
  Problem is when I am clicking on a button, only for the first time click is see "Loaded ensure runtime" message which is showing from 1.bundle.js</p>
  
  <p>Clicking again on the button I cannot see the message "Loaded ensure runtime"</p>
  
  <p>My overall motive is to load the bundle and its contained module dynamically.</p>