Skip to content

Commit 420b475

Browse files
committed
fix(prism): load prismjs core before language components
prismjs language components (prismjs/components/prism-*) register on the global Prism that core installs; importing a component before core throws 'Prism is not defined' (in SSR and the client). The @sim/emcn extraction changed bundling so core no longer loaded eagerly first, exposing the latent bad order on the home (chat-content) and workflow-editor pages. - chat-content.tsx: import prismjs core first (it needs ts/bash/css/markup, which emcn does not register). - code-editor.tsx, input-format.tsx, code.tsx: drop the redundant prism-json/prism-python imports — these highlight via emcn's languages, which already registers js/json/python in the correct order.
1 parent f5116f4 commit 420b475

4 files changed

Lines changed: 7 additions & 7 deletions

File tree

apps/sim/app/workspace/[workspaceId]/home/components/message-content/components/chat-content/chat-content.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
import { type ComponentPropsWithoutRef, memo, useEffect, useMemo, useRef } from 'react'
44
import { Streamdown } from 'streamdown'
55
import 'streamdown/styles.css'
6+
// prismjs core must load before its language components — they register on the
7+
// global `Prism` it installs (on `window`/`global`); fixes SSR + client order.
8+
import 'prismjs'
69
import 'prismjs/components/prism-typescript'
710
import 'prismjs/components/prism-bash'
811
import 'prismjs/components/prism-css'

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/components/code/code.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
import type { ReactElement } from 'react'
22
import { memo, useCallback, useEffect, useImperativeHandle, useMemo, useRef, useState } from 'react'
3-
import { Check, Wand2 } from 'lucide-react'
4-
import { useParams } from 'next/navigation'
5-
import 'prismjs/components/prism-python'
63
import {
74
CODE_LINE_HEIGHT_PX,
85
Code as CodeEditor,
@@ -14,6 +11,8 @@ import {
1411
languages,
1512
} from '@sim/emcn'
1613
import { createLogger } from '@sim/logger'
14+
import { Check, Wand2 } from 'lucide-react'
15+
import { useParams } from 'next/navigation'
1716
import Editor from 'react-simple-code-editor'
1817
import { Button } from '@/components/ui/button'
1918
import { CodeLanguage } from '@/lib/execution/languages'

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/components/starter/input-format.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
11
import { useCallback, useRef } from 'react'
2-
import { Trash } from '@sim/emcn/icons'
3-
import { Plus } from 'lucide-react'
4-
import 'prismjs/components/prism-json'
52
import {
63
Badge,
74
Button,
@@ -19,6 +16,8 @@ import {
1916
Label,
2017
languages,
2118
} from '@sim/emcn'
19+
import { Trash } from '@sim/emcn/icons'
20+
import { Plus } from 'lucide-react'
2221
import Editor from 'react-simple-code-editor'
2322
import { createDefaultInputFormatField } from '@/lib/workflows/input-format'
2423
import { formatDisplayText } from '@/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/components/formatted-text'

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/components/tool-input/components/code-editor/code-editor.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import type { ReactElement } from 'react'
22
import { useEffect, useRef, useState } from 'react'
3-
import 'prismjs/components/prism-json'
43
import {
54
CODE_LINE_HEIGHT_PX,
65
Code,

0 commit comments

Comments
 (0)