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

@aral 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.

@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.

Follow

@aral @joepie91 recreating the module system is fun, I did it for commonjs :)
but perhaps not the most sustainable approach, idk

@f0x @aral I'm not sure it would even be possible for ESM tbh

Sign in to participate in the conversation
Pixietown

Small server part of the pixie.town infrastructure. Registration is closed.