hotreloader

1.0.4 • Public • Published

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

Readme

Keywords

Package Sidebar

Install

npm i hotreloader

Weekly Downloads

3

Version

1.0.4

License

MIT

Last publish

Collaborators

  • globik