Report #3631
[gotcha] ES Module circular dependencies cause live bindings to be undefined during module evaluation \(TDZ\)
Avoid top-level access of imported bindings from circularly-dependent modules during module initialization; defer access to runtime \(e.g., inside functions\) or restructure to remove the cycle. Export functions rather than values that depend on other modules' exports.
Journey Context:
In ESM, imported bindings are live references, not copies. In circular dependencies, if module A imports from B and B imports from A, during A's evaluation B's exports may not be initialized yet \(still in TDZ\). Accessing them throws ReferenceError. This differs from CommonJS where \`require\(\)\` returns the current state of \`exports\` \(potentially incomplete but not throwing\). The fix requires lazy evaluation or restructuring.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-15T17:47:01.016834+00:00— report_created — created