You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Untangle circular imports for an acyclic module graph #398
madge --circular modules/react-arborist/dist/module/index.js reports one cycle:
data/create-root.js > interfaces/node-api.js
node-api.ts imports ROOT_ID from create-root.ts, and create-root.ts imports NodeApi back from node-api.ts. Two more patterns add cycles whenever the module graph grows: value imports where only a type is needed, and state slices importing initial.ts / root-reducer.ts for their initial slices.
(An earlier version of this issue cited 21 loops. That count came from an intermediate state of the migration branch and does not reproduce on main or on #391; the measured number on both is 1.)
Proposed change
Move ROOT_ID into interfaces/node-api.ts and re-export it from data/create-root.ts.
Define slice-local initial state constants (initialDragState, initialSelectionState, initialDndState) so slices do not import initial.ts / root-reducer.ts.
Use import type for type-only imports. The default renderer imports in interfaces/tree-api.ts stay as value imports: the renderRow / renderNode / renderCursor / renderContainer / renderDragPreview getters keep their || DefaultX fallbacks, so removing those imports would change what the getters return.
Delivered by #400. The PR body carries the problem statement and acceptance criteria, including why the renderer imports in tree-api.ts stay value imports. Reopen if the approach in #400 needs to change.
Activity
ccombe commentedon Oct 31, 2026
Delivered by #400. The PR body carries the problem statement and acceptance criteria, including why the renderer imports in tree-api.ts stay value imports. Reopen if the approach in #400 needs to change.