Skip to content

Node.js modules hotreloader. No need the server to restart.

License

Notifications You must be signed in to change notification settings

Globik/hotreloader

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 

Repository files navigation

hotreloader

Node.js modules hot reloader. No need the server to restart.

NPM version NPM Downloads

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

About

Node.js modules hotreloader. No need the server to restart.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published