title: Webpack hot module replacement in server code
body: <p>All the webpack examples I have looked at so far deal with client side hot module replacement, for example: <a href="http://andrewhfarmer.com/webpack-hmr-tutorial/" rel="noreferrer">this</a> and <a href="https://github.com/glenjamin/webpack-hot-middleware/blob/master/example/server.js" rel="noreferrer">this</a>.</p>
  
  <p>According to the webpack document, one can use EITHER webpack-dev-server OR middlewares (webpack-dev-webpack-dev-middleware and webpack-hot-middleware, along with <code>webpack-hot-middleware/client</code> in a config <code>entry</code>, and integrated into e.g. express js) to enable hot module replacement for client side codes</p>
  
  <p>Is it possible to enable hot module replacement for server side codes? The document does shows an <a href="http://webpack.github.io/docs/hot-module-replacement.html" rel="noreferrer">example</a></p>
  
  <pre class="lang-js prettyprint-override"><code>var requestHandler = require("./handler.js");
  var server = require("http").createServer();
  server.on("request", requestHandler);
  server.listen(8080);
  
  // check if HMR is enabled
  if(module.hot) {
      // accept update of dependency
      module.hot.accept("./handler.js", function() {
          // replace request handler of server
          server.removeListener("request", requestHandler);
          requestHandler = require("./handler.js");
          server.on("request", requestHandler);
      });
  }
  </code></pre>
  
  <p>The document is quite spare in explanation.</p>
  
  <p>So the question is, how would hot module replacement be implemented in server side code without restarting the server? (At the moment, I have nodemon watching server side code to restart the server on file changes)</p>