kentor / www.kentor.dev

Writing on Web Development
https://www.kentor.dev
6 stars 0 forks source link

Node.js hot module reloading development #2

Open Globik opened 7 years ago

Globik commented 7 years ago

Hi. How to use your system in practice? Let's say there are hot-reloading modules. For example npm 'reloadjs' there is. var reload=require('reloadjs') var reloadable=reload('reloadables_some_module.js') var radius=reloadable.circle(5) console.log(radius) //and after some file changes again call radius to the console.log So works it. But what about your implementation? In your blog article I can't see how to use it in practice. I mean I don't undestand the whole pic. Can you provide to the readers a simple hello world example? Please.

kentor commented 7 years ago

Yeah ok I will give a better and clear example in a few days and update my blog

kentor commented 7 years ago

Well I updated my blog post with an animation to see how it works:

https://kentor.me/posts/node-js-hot-reloading-development/

Also I updated this boilerplate to get something minimal started:

https://github.com/kentor/node-hot-reloading-boilerplate

I hope that helps

Globik commented 7 years ago

Thank you for your boilerplate. It seems I understand now. I am using npm reloadjs.js and it has two issues. One is memory leaks after two hours of work processing And two is some times the require.cache is empty if the watched file is too large. That feeling that chokidar does not hurry write the changes to disk. So I look some alternative. But I think it is chokidar faults, its options. And the code.