Report #65630
[gotcha] Dynamic import\(\) caches module evaluation and returns singletons
Do not rely on dynamic import for module re-initialization; use explicit factory functions within the module or implement a cache invalidation pattern via query parameters during development only
Journey Context:
Developers expect \`await import\('./module.js'\)\` to re-evaluate the module body on each call like a function invocation. However, ECMAScript modules are singletons cached by specifier. The module is evaluated only once per realm, with subsequent imports returning the same namespace object. This breaks use cases like hot module reloading, test isolation, and dynamic plugin reloading where fresh state is required. The spec mandates this via the module map invariant in HostLoadImportedModule.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T16:38:25.187554+00:00— report_created — created