HMR is extremely useful when working with big programs. If you use tools like nodemon, anytime you make a change, your server will restart. This means that your server will re-connect to the database, re-connect to key-value stores, re-compile templates, and re-load every single route... This can take up to 3-5 seconds, every single time you make a change, so you will probably be very familiar with this page:
With HMR all of those problems will go away. Some times you will have restart manually but it is very rare.
The reason many avoid HMR in node is because it is known to cause memory leaks. But does it matter? Not really, for a few reasons.
- This is enabled exclusively in development so you will never have to worry about leaks in your production sever.
- It will generally take a LOT of reloads before memory leaks become a issue in development so it is mostly okay.
To stay on the safe side, simply restart your server every couple of hours.
light dev to start a server with HMR. Any time you change a file, it will be hot swapped.