Node.js modules hot reloader. No need the server to restart.
npm install hotreloader
const reload = require('hotreloader');
// const myModule = require('./myModule.js');
// for myModule.js to reloading you can do so:
const count = reload('./myModule.js') // it's the same like require('./myModule.js')
console.log(count.count());
console.log(count.count());
var cnt = 0;
var count = () = > {
return cnt++;
}
module.exports={count};
Please make changes in a file and then in a router call that module file
const reload = require('hotreloader');
var count = reload('./myModule.js');
router.get('/', async ctx = > {
ctx.body = count.count();
})
Fs watchifying based on chokidar. Its options hardcoded as follows:
{ ignored: /[\/\\]\./, persistent: true,awaitWriteFinish:{stabilityThreshold:2000,pollInterval:100} }
hotreloader.js
works in the module 'koa-rend'
MIT