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…
Invalidate cache when using import · Issue #307 · nodejs/modules
How do I invalidate the cache of import? I have a function that installs missing modules when an import fails, but the import statement seems to preserve the failure while the script is still runni...GitHub
Sven Slootweg
in reply to Aral Balkan • • •Aral Balkan
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.