Skip to main content


The current officially-sanctioned Node.js method of performing ESM hot module reloading is to (I kid you not) “leak memory.”

Je désespère!

github.com/nodejs/modules/issu…

#nodeJS #ESM

in reply to Aral Balkan

While I do think this is a real issue (and *yet another* reason why ESM is not a suitable replacement for CJS), it should be noted that hot-reloading modules is never a safe thing to do in JS regardless of the module system - the language does not provide sufficient state isolation guarantees to prevent state leaking between versions of modules, and this can lead to very strange non-reproducible bugs.
in reply to Sven Slootweg

@joepie91 Indeed. And yet needs must :)

That said, I’ve actually decided to try a far more pragmatic approach that I’m pretty sure will handle the 80% use case very well. And I plan on seeing how much closer I can get that to 100% over time.

Otherwise, you’re looking at either memory leaks, using workers, or ­– if you keep going down the rabbit hole (which I’ve done several times now) – recreating Node’s module system.