Skip to content

Commit 1e4d119

Browse files
committed
Turbopack: fix import chain by determining depth locally per route
1 parent 5b97f1f commit 1e4d119

File tree

9 files changed

+457
-230
lines changed

9 files changed

+457
-230
lines changed

apps/bundle-analyzer/app/page.tsx

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

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

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

@@ -332,6 +341,7 @@ export default function Home() {
332341
startFileId={selectedSourceIndex}
333342
analyzeData={analyzeData}
334343
modulesData={modulesData}
344+
depthMap={moduleDepthMap}
335345
filterSource={filterSource}
336346
/>
337347
)}

0 commit comments

Comments
 (0)