Skip to content

Commit da1efea

Browse files
committed
perf(editor): lazy-load NoteBlock so Streamdown is off the editor's critical path
1 parent 7ead8b2 commit da1efea

1 file changed

Lines changed: 17 additions & 1 deletion

File tree

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/workflow-constants.ts

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,25 @@
1+
import dynamic from 'next/dynamic'
12
import type { EdgeTypes, NodeTypes } from 'reactflow'
23
import { SubflowNodeComponent } from '@/app/workspace/[workspaceId]/w/[workflowId]/components'
3-
import { NoteBlock } from '@/app/workspace/[workspaceId]/w/[workflowId]/components/note-block/note-block'
44
import { WorkflowBlock } from '@/app/workspace/[workspaceId]/w/[workflowId]/components/workflow-block/workflow-block'
55
import { WorkflowEdge } from '@/app/workspace/[workspaceId]/w/[workflowId]/components/workflow-edge/workflow-edge'
66

7+
/**
8+
* Lazily loaded note node. Defined once at module scope so the {@link nodeTypes}
9+
* map stays referentially stable for ReactFlow. Loading it dynamically keeps its
10+
* heavy markdown dependencies (Streamdown, remark-breaks) off the editor's
11+
* critical path — they load only when a workflow actually contains a note block.
12+
* `ssr: false` is safe because the note node is canvas-only and never rendered
13+
* on the server.
14+
*/
15+
const NoteBlock = dynamic(
16+
() =>
17+
import('@/app/workspace/[workspaceId]/w/[workflowId]/components/note-block/note-block').then(
18+
(mod) => mod.NoteBlock
19+
),
20+
{ ssr: false }
21+
)
22+
723
/** Custom node types for ReactFlow. */
824
export const nodeTypes: NodeTypes = {
925
workflowBlock: WorkflowBlock,

0 commit comments

Comments
 (0)