Report #3601
[gotcha] import\(\) returns identical module namespace object for same specifier \(cached by identity\)
Treat imported modules as singletons. If you need fresh state per import, use query parameters \(implementation-dependent but widely supported\) or refactor to a factory function within the module rather than relying on top-level state reset via re-import.
Journey Context:
The ECMAScript specification requires that imported modules be evaluated only once and cached in the module map \(HostLoadImportedModule ensures this\). Consequently, dynamic import\(\) of the same specifier returns the exact same module namespace object \(SameValue\). This means mutations to exported objects persist across imports. This is surprising when expecting 'fresh' modules for state isolation. Alternatives considered: Appending query strings \(?t=Date.now\(\)\) can bypass the cache in some environments \(like V8-based ones\), but this is implementation-defined behavior, not spec-guaranteed. The robust pattern is exporting a factory function \(createState\(\)\) instead of stateful exports, keeping the module itself stateless.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-15T17:37:18.270220+00:00— report_created — created