Skip to content

Commit 25eef2f

Browse files
committed
Turbopack: fix import chain by determining depth locally per route
1 parent bf74f3a commit 25eef2f

File tree

10 files changed

+467
-230
lines changed

10 files changed

+467
-230
lines changed

apps/bundle-analyzer/app/page.tsx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import { Input } from '@/components/ui/input'
1414
import { Skeleton, TreemapSkeleton } from '@/components/ui/skeleton'
1515
import { ToggleGroup, ToggleGroupItem } from '@/components/ui/toggle-group'
1616
import { AnalyzeData, ModulesData } from '@/lib/analyze-data'
17+
import { computeActiveEntries, computeModuleDepthMap } from '@/lib/module-graph'
1718
import { SpecialModule } from '@/lib/types'
1819
import { getSpecialModuleType } from '@/lib/utils'
1920

@@ -99,6 +100,14 @@ export default function Home() {
99100
return () => window.removeEventListener('keydown', handleKeyDown)
100101
}, [])
101102

103+
// Compute module depth map from active entries
104+
const moduleDepthMap = useMemo(() => {
105+
if (!modulesData || !analyzeData) return new Map()
106+
107+
const activeEntries = computeActiveEntries(modulesData, analyzeData)
108+
return computeModuleDepthMap(modulesData, activeEntries)
109+
}, [modulesData, analyzeData])
110+
102111
const filterSource = useMemo(() => {
103112
if (!analyzeData) return undefined
104113

@@ -335,6 +344,7 @@ export default function Home() {
335344
startFileId={selectedSourceIndex}
336345
analyzeData={analyzeData}
337346
modulesData={modulesData}
347+
depthMap={moduleDepthMap}
338348
filterSource={filterSource}
339349
/>
340350
)}

0 commit comments

Comments
 (0)