Skip to content

Commit 4edda92

Browse files
fix: remove dynamic import statements
1 parent 18d5563 commit 4edda92

3 files changed

Lines changed: 27 additions & 53 deletions

File tree

src/api/analysis/analysis.ts

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@ import {
1313
import { buildUrl } from '../utils'
1414
import { cpToWinrate } from 'src/lib/stockfish'
1515
import { AvailableMoves } from 'src/types/training'
16+
import { Chess } from 'chess.ts'
17+
import {
18+
saveCustomAnalysis,
19+
getCustomAnalysisById,
20+
} from 'src/lib/customAnalysis'
1621

1722
function buildGameTree(moves: any[], initialFen: string) {
1823
const tree = new GameTree(initialFen)
@@ -405,7 +410,6 @@ const createAnalyzedGameFromPGN = async (
405410
pgn: string,
406411
id?: string,
407412
): Promise<AnalyzedGame> => {
408-
const { Chess } = await import('chess.ts')
409413
const chess = new Chess()
410414

411415
try {
@@ -476,8 +480,6 @@ export const getAnalyzedCustomPGN = async (
476480
pgn: string,
477481
name?: string,
478482
): Promise<AnalyzedGame> => {
479-
const { saveCustomAnalysis } = await import('src/lib/customAnalysis')
480-
481483
const stored = await saveCustomAnalysis('pgn', pgn, name)
482484

483485
return createAnalyzedGameFromPGN(pgn, stored.id)
@@ -487,7 +489,6 @@ const createAnalyzedGameFromFEN = async (
487489
fen: string,
488490
id?: string,
489491
): Promise<AnalyzedGame> => {
490-
const { Chess } = await import('chess.ts')
491492
const chess = new Chess()
492493

493494
try {
@@ -531,8 +532,6 @@ export const getAnalyzedCustomFEN = async (
531532
fen: string,
532533
name?: string,
533534
): Promise<AnalyzedGame> => {
534-
const { saveCustomAnalysis } = await import('src/lib/customAnalysis')
535-
536535
const stored = await saveCustomAnalysis('fen', fen, name)
537536

538537
return createAnalyzedGameFromFEN(fen, stored.id)
@@ -541,8 +540,6 @@ export const getAnalyzedCustomFEN = async (
541540
export const getAnalyzedCustomGame = async (
542541
id: string,
543542
): Promise<AnalyzedGame> => {
544-
const { getCustomAnalysisById } = await import('src/lib/customAnalysis')
545-
546543
const stored = getCustomAnalysisById(id)
547544
if (!stored) {
548545
throw new Error('Custom analysis not found')

src/pages/analysis/[...id].tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ import { tourConfigs } from 'src/constants/tours'
5858
import type { DrawShape } from 'chessground/draw'
5959
import { MAIA_MODELS } from 'src/constants/common'
6060
import { applyEngineAnalysisData } from 'src/lib/analysisStorage'
61+
import { deleteCustomAnalysis } from 'src/lib/customAnalysis'
6162

6263
const AnalysisPage: NextPage = () => {
6364
const { startTour, tourState } = useTour()
@@ -423,7 +424,6 @@ const Analysis: React.FC<Props> = ({
423424
analyzedGame.type === 'custom-pgn' ||
424425
analyzedGame.type === 'custom-fen'
425426
) {
426-
const { deleteCustomAnalysis } = await import('src/lib/customAnalysis')
427427
deleteCustomAnalysis(analyzedGame.id)
428428
toast.success('Custom analysis deleted')
429429
router.push('/analysis')

src/pages/openings/index.tsx

Lines changed: 21 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,7 @@
11
import Head from 'next/head'
22
import { NextPage } from 'next'
33
import { useRouter } from 'next/router'
4-
import {
5-
useState,
6-
useEffect,
7-
useContext,
8-
useCallback,
9-
useMemo,
10-
Suspense,
11-
lazy,
12-
} from 'react'
4+
import { useState, useEffect, useContext, useCallback, useMemo } from 'react'
135
import { Chess, PieceSymbol } from 'chess.ts'
146
import { AnimatePresence, motion } from 'framer-motion'
157
import type { Key } from 'chessground/types'
@@ -25,12 +17,7 @@ import { DrillConfiguration, AnalyzedGame } from 'src/types'
2517
import { GameNode } from 'src/types/base/tree'
2618
import { MIN_STOCKFISH_DEPTH } from 'src/constants/analysis'
2719
import openings from 'src/lib/openings/openings.json'
28-
29-
const LazyOpeningDrillAnalysis = lazy(() =>
30-
import('src/components/Openings/OpeningDrillAnalysis').then((module) => ({
31-
default: module.OpeningDrillAnalysis,
32-
})),
33-
)
20+
import { OpeningDrillAnalysis } from 'src/components/Openings/OpeningDrillAnalysis'
3421

3522
import {
3623
OpeningSelectionModal,
@@ -841,34 +828,24 @@ const OpeningsPage: NextPage = () => {
841828
id="analysis"
842829
className="desktop-right-column-container flex flex-col gap-2"
843830
>
844-
<Suspense
845-
fallback={
846-
<div className="flex h-full items-center justify-center">
847-
<div className="text-sm text-secondary">
848-
Loading analysis...
849-
</div>
850-
</div>
851-
}
852-
>
853-
{analyzedGame && (
854-
<LazyOpeningDrillAnalysis
855-
currentNode={controller.currentNode}
856-
gameTree={treeController.gameTree}
857-
analysisEnabled={controller.analysisEnabled}
858-
onToggleAnalysis={() =>
859-
controller.setAnalysisEnabled(!controller.analysisEnabled)
860-
}
861-
playerColor={controller.currentDrill?.playerColor || 'white'}
862-
maiaVersion={
863-
controller.currentDrill?.maiaVersion || 'maia_kdd_1500'
864-
}
865-
analysisController={analysisController}
866-
hover={hover}
867-
setHoverArrow={setHoverArrow}
868-
makeMove={makeMove}
869-
/>
870-
)}
871-
</Suspense>
831+
{analyzedGame && (
832+
<OpeningDrillAnalysis
833+
currentNode={controller.currentNode}
834+
gameTree={treeController.gameTree}
835+
analysisEnabled={controller.analysisEnabled}
836+
onToggleAnalysis={() =>
837+
controller.setAnalysisEnabled(!controller.analysisEnabled)
838+
}
839+
playerColor={controller.currentDrill?.playerColor || 'white'}
840+
maiaVersion={
841+
controller.currentDrill?.maiaVersion || 'maia_kdd_1500'
842+
}
843+
analysisController={analysisController}
844+
hover={hover}
845+
setHoverArrow={setHoverArrow}
846+
makeMove={makeMove}
847+
/>
848+
)}
872849
</div>
873850
</div>
874851
</div>
@@ -1046,7 +1023,7 @@ const OpeningsPage: NextPage = () => {
10461023
{/* Analysis Components Stacked */}
10471024
<div className="flex w-full flex-col gap-1 overflow-hidden">
10481025
{analyzedGame && (
1049-
<LazyOpeningDrillAnalysis
1026+
<OpeningDrillAnalysis
10501027
currentNode={controller.currentNode}
10511028
gameTree={treeController.gameTree}
10521029
analysisEnabled={controller.analysisEnabled}

0 commit comments

Comments
 (0)