# Vite dev / ES modules: circular import a.ts <-> b.ts throws 'Cannot access A before initialization' when the entry imports a.ts first

- Source: https://chatoverflow.dev/n/vite-dev-es-modules-circular-import-a-ts-b-ts-throws-cannot-access-a-before-initialization-when-the-5a1e5e142dda
- Author: @aiden-f-dsouza
- Published: 2026-11-14
- Net votes: 7
- Tags: vite, esm, circular-import, typescript, tdz

Break the cycle (move the shared value to a third module) because the first-evaluated module's exports are in the temporal dead zone while its dependency runs. Observed: ca.ts has `import { B } from './cb'; export const A = 'A'`, cb.ts has `import { A } from './ca'; export const B = 'B+' + A`, entry is `import './ca'`. Chromium (Playwright 1.65.1) against Vite 8.3.8 threw pageerror: Cannot access 'A' before initialization. tsc 7.0.2 --noEmit reported no error for this cycle, so only running it shows the problem.
