Skip to content

Fix and prevent circular dependencies #2458

@mimecuvalo

Description

@mimecuvalo

We currently have some circular dependencies in the codebase, found using the vite-plugin-circular-dependency plugin.

  ../../packages/state/src/lib/core/EffectScheduler.ts
  	../../packages/state/src/lib/core/EffectScheduler.ts -> ../../packages/state/src/lib/core/transactions.ts


  ../../packages/editor/src/index.ts
  	../../packages/editor/src/index.ts -> ../../packages/editor/src/lib/TldrawEditor.tsx -> ../../packages/editor/src/lib/components/Canvas.tsx -> ../../packages/editor/src/lib/components/ShapeIndicator.tsx -> ../../packages/editor/src/lib/hooks/useEditorComponents.tsx


  ../../packages/editor/src/lib/components/Canvas.tsx
  	../../packages/editor/src/lib/components/Canvas.tsx -> ../../packages/editor/src/lib/components/default-components/DefaultErrorFallback.tsx -> ../../packages/editor/src/lib/hooks/useEditorComponents.tsx


  ../../packages/editor/src/lib/TldrawEditor.tsx
  	../../packages/editor/src/lib/TldrawEditor.tsx -> ../../packages/editor/src/lib/components/default-components/DefaultLoadingScreen.tsx


  ../../packages/tldraw/src/lib/shapes/frame/FrameShapeUtil.tsx
  	../../packages/tldraw/src/lib/shapes/frame/FrameShapeUtil.tsx -> ../../packages/tldraw/src/lib/shapes/frame/components/FrameHeading.tsx -> ../../packages/tldraw/src/lib/shapes/frame/components/FrameLabelInput.tsx

We should aim to fix these and put guardrails in place so it doesn't happen in the future. (It looks like circleImportThrowErr will help do this in the plugin).

I came across this as I was trying to write some Jest tests for my PR (I was trying to set up a mock for @tldraw/editor) but it looks like it wsa hampered by running into a circ. dep. issue.

cc @ds300 this might need your eyes, at least on the first one with EffectScheduler

Metadata

Metadata

Assignees

No one assigned

    Labels

    keep⚙️ Prevents issue from being marked stale or closed

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions