File tree Expand file tree Collapse file tree 3 files changed +27
-1
lines changed
Expand file tree Collapse file tree 3 files changed +27
-1
lines changed Original file line number Diff line number Diff line change @@ -24,4 +24,20 @@ cp -r "$LATEST_HASH/charting_library" src/utils/
2424cp -r " $LATEST_HASH /datafeeds" public/
2525cp -r " $LATEST_HASH /datafeeds" src/utils/
2626
27+ # Create index.js to export widget for Next.js compatibility
28+ cat > " src/utils/charting_library/index.js" << 'JSEOF '
29+ // The charting library is loaded via a UMD bundle that attaches to window.TradingView
30+ // We provide a stub that resolves to the actual widget at runtime
31+ export const widget = (typeof window !== 'undefined' && typeof window.TradingView !== 'undefined')
32+ ? window.TradingView.widget
33+ : class MockWidget {}
34+ JSEOF
35+
36+ # Create index.d.ts to re-export types
37+ cat > " src/utils/charting_library/index.d.ts" << 'DTSEOF '
38+ // Re-export all types from the charting library
39+ export * from './charting_library.d'
40+ export * from './datafeed-api.d'
41+ DTSEOF
42+
2743remove_if_directory_exists " $LATEST_HASH "
Original file line number Diff line number Diff line change @@ -105,6 +105,13 @@ const nextConfig = {
105105 use : [ '@svgr/webpack' ] ,
106106 } )
107107
108+ // Handle charting library - it's a UMD bundle that needs special treatment
109+ config . resolve . alias = {
110+ ...config . resolve . alias ,
111+ // Ensure the charting library is resolved correctly
112+ 'utils/charting_library' : require . resolve ( './src/utils/charting_library/index.js' ) ,
113+ }
114+
108115 return config
109116 } ,
110117}
Original file line number Diff line number Diff line change 11import { useEffect , useMemo } from 'react'
22import { useLocation } from 'react-router-dom'
3+ import dynamic from 'next/dynamic'
34
45import GridWithSplitters from 'components/common/Grid/GridWithSplitters'
56import AccountDetailsCard from 'components/trade/AccountDetailsCard'
6- import TradeChart from 'components/trade/TradeChart'
77import TradeModule from 'components/trade/TradeModule'
8+
9+ // TradeChart uses the charting library which is browser-only, so we load it dynamically
10+ const TradeChart = dynamic ( ( ) => import ( 'components/trade/TradeChart' ) , { ssr : false } )
811import { getDefaultChainSettings } from 'constants/defaultSettings'
912import { LocalStorageKeys } from 'constants/localStorageKeys'
1013import useTradeEnabledAssets from 'hooks/assets/useTradeEnabledAssets'
You can’t perform that action at this time.
0 commit comments