logoalt Hacker News

Implementing native Node.js hot modules (technical write up)

8 pointsby 90s_devlast Saturday at 12:13 PM1 commentview on HN

Comments

cyco130last Wednesday at 1:52 PM

I believe at least the Vitest project considered using node:module hooks for live reloading but rejected it in the past. The reason given to me was that, there is no way to garbage-collect a real EcmaScript module since they're always reachable by the module ID string as per the specification.

This kind of leak was deemed acceptable in a browser tab (which we tend to close or reload often) but unacceptable for a long-running server process.

Pseudo-modules based on node:vm, on the other hand, will be collected normally when they become unreachable.