hotreloader
v1.0.4
Published
For node.js modules hot-reloading. No need the server to restart.
Downloads
12
Readme
hotreloader
Node.js modules hot reloader. No need the server to restart.
Install
npm install hotreloader
Usage
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());
myModule.js
var cnt = 0;
var count = () = > {
return cnt++;
}
module.exports={count};
Then in a router(as example based on koa.js)
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();
})
Chokidar
Fs watchifying based on chokidar. Its options hardcoded as follows:
{ ignored: /[\/\\]\./, persistent: true,awaitWriteFinish:{stabilityThreshold:2000,pollInterval:100} }
Projects
hotreloader.js
works in the module 'koa-rend'
Happy coding!
License
MIT