```js const { createServer } = require("http");
npm install hot-modulehot-module``js
const { createServer } = require("http");
// 👇 Polyfill module.hot
require("hot-module")();
if (module.hot) {
// 👇 Watch ./app for changes./app
module.hot.accept("./app", function() {
console.log("🔁 HMR Reloading ");
});
console.info("✅ Server-side HMR Enabled!");
} else {
console.info("❌ Server-side HMR Not Supported.");
}
createServer((req, res) => {
// 👇 Always reference latest ./app between requests``
require("./app")(req, res);
}).listen(3000, () => {
console.log("🚀 Listening at http://localhost:3000");
});
- hot-module-replacement
- node-dev
- nodemon
- piping
- webpack-hot-server-example