From fa8e2714cab9e32100f638e7584b6a0bdc6ad7a2 Mon Sep 17 00:00:00 2001 From: hailin Date: Sun, 5 Apr 2026 21:43:05 -0700 Subject: [PATCH] fix: use conditional require for echarts-wordcloud instead of dynamic import Dynamic import was async and wordcloud plugin wasn't loaded before setOption was called. Now uses synchronous require() guarded by typeof window check to avoid SSR crash. Co-Authored-By: Claude Opus 4.6 (1M context) --- frontend/src/frameworks/components/charts/EChartsBase.tsx | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/frontend/src/frameworks/components/charts/EChartsBase.tsx b/frontend/src/frameworks/components/charts/EChartsBase.tsx index e4617f7..b4d62a5 100644 --- a/frontend/src/frameworks/components/charts/EChartsBase.tsx +++ b/frontend/src/frameworks/components/charts/EChartsBase.tsx @@ -2,6 +2,8 @@ import React, { useEffect, useRef } from 'react'; import * as echarts from 'echarts'; +// eslint-disable-next-line @typescript-eslint/no-require-imports +if (typeof window !== 'undefined') { require('echarts-wordcloud'); } import { useThemeStore } from '@/adapters/state/zustand/themeStore'; // --------------------------------------------------------------------------- @@ -41,11 +43,6 @@ export const EChartsBase: React.FC = ({ const chartRef = useRef(null); const currentTheme = useThemeStore((s) => s.currentTheme); - // Load echarts-wordcloud plugin on client side only - useEffect(() => { - import('echarts-wordcloud').catch(() => {}); - }, []); - // Init / re-init when theme changes useEffect(() => { if (!containerRef.current) return;