开发者社区> 镜像站> NPM> hot-module
hot-module
```js const { createServer } = require("http");
Last updated 2 years ago by ericclemmons .
Original npm · Tarball · package.json
$ cnpm install hot-module 
SYNC missed versions from official npm registry.

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

Current Tags

  • 1.0.1                                ...           latest (2 years ago)

2 Versions

  • 1.0.1                                ...           2 years ago
  • 1.0.0                                ...           2 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 1
Dependencies (2)
Dev Dependencies (1)
  • np ^3.0.4
Dependents (0)
None