Miss any of our Open RFC calls?Watch the recordings here! »

hot-module

1.0.1 • Public • Published

hot-module

const { createServer } = require("http");
 
// 👇 Polyfill `module.hot`
require("hot-module")();
 
if (module.hot) {
  // 👇 Watch `./app` for changes
  module.hot.accept("./app", function() {
    console.log("🔁  HMR Reloading `./app`");
  });
 
  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");
});

Related Projects

Keywords

none

Install

npm i hot-module

DownloadsWeekly Downloads

70

Version

1.0.1

License

none

Unpacked Size

68.7 kB

Total Files

5

Last publish

Collaborators

  • avatar