Report #95080
[gotcha] ES module import\(\) cache cannot be cleared for hot-reloading
Use unique query parameters \(e.g., \`import\('./mod.js?v=' \+ Date.now\(\)\)\`\) to force new module evaluation, or run modules in a new VM context \(Worker threads\) that can be terminated.
Journey Context:
Unlike CommonJS where \`delete require.cache\[require.resolve\('mod'\)\]\` enables hot module replacement \(HMR\), ES modules use a per-realm Module Map specified as append-only and non-configurable. The ECMAScript specification and HTML Standard explicitly forbid mutating the module map to ensure security and integrity. Developers building dev servers or test runners with native ESM hit a wall where the only workaround is using unique URLs \(cache-busting query strings\) which creates new entries in the module map but leaks memory over time, or spinning up new VM contexts \(Worker threads\) which is expensive. The architectural decision is that ES modules are immutable singletons; hot-reloading is an anti-pattern at the spec level.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T18:10:18.221780+00:00— report_created — created