Unverified Commit 2319b65b authored by Will Binns-Smith's avatar Will Binns-Smith Committed by GitHub

Virtualize bundle analyzer source table (#98539)

Virtualize source rows with `react-virtuoso` to avoid mounting the full
table at once.

Preserve sorting, filtering, grouped package expansion, sticky headers,
totals, selection, and semantic table markup. Render an additional
viewport around the visible range to avoid blank content during fast
scrolling.

<!-- NEXT_JS_LLM -->
Co-authored-by: 's avatarvercel-fleet-prod[bot] <318278635+vercel-fleet-prod[bot]@users.noreply.github.com>
Co-authored-by: 's avatarWill Binns-Smith <755844+wbinnssmith@users.noreply.github.com>
parent 3a5205b8
......@@ -22,7 +22,11 @@ import { TopBar, Environment, CompareView } from '@/components/top-bar'
import { TreemapVisualizer } from '@/components/treemap-visualizer'
import { Badge } from '@/components/ui/badge'
import { TableSkeleton, TreemapSkeleton } from '@/components/ui/skeleton'
import {
AnalyzerChromeSkeleton,
TableSkeleton,
TreemapSkeleton,
} from '@/components/ui/skeleton'
import { AnalyzeData, ModulesData } from '@/lib/analyze-data'
import {
analyzeDataUrl,
......@@ -109,14 +113,7 @@ class AnalyzerErrorBoundary extends Component<
}
function AnalyzerFallback({ view }: { view: CompareView }) {
return (
<main className="h-screen flex flex-col bg-background">
<div className="h-14 flex-none border-b border-border" />
<div className="flex-1 min-h-0 p-4">
{view === CompareView.Table ? <TableSkeleton /> : <TreemapSkeleton />}
</div>
</main>
)
return <AnalyzerChromeSkeleton view={view} />
}
function useAnalyzerModel(compare: boolean) {
......
......@@ -35,16 +35,18 @@ export function TreemapSkeleton() {
export function TableSkeleton() {
return (
<div className="flex h-full w-full flex-col p-4" aria-hidden="true">
<div className="flex h-9 items-center gap-4 border-b border-border px-3">
<Skeleton className="h-3 w-1/2" />
<Skeleton className="h-3 w-24" />
<Skeleton className="h-3 w-24" />
<div className="flex h-9 flex-none items-center gap-4 border-b border-border px-3">
<div className="flex h-full w-full items-center gap-4">
<Skeleton className="h-3 w-1/2" />
<Skeleton className="h-3 w-24" />
<Skeleton className="h-3 w-24" />
</div>
</div>
{/* Placeholder rows fill the viewport; this is not the table's page size. */}
{Array.from({ length: 12 }, (_, index) => (
{Array.from({ length: 32 }, (_, index) => (
<div
key={index}
className="flex min-h-0 flex-1 items-center gap-4 border-b border-border/60 px-3"
className="flex h-9 flex-none items-center gap-4 border-b border-border/60 px-3"
>
<Skeleton
className="h-3"
......@@ -57,3 +59,54 @@ export function TableSkeleton() {
</div>
)
}
export function AnalyzerChromeSkeleton({
view,
}: {
view: 'table' | 'treemap'
}) {
return (
<main className="flex h-screen flex-col overflow-hidden bg-background">
<div className="flex h-14 flex-none items-center gap-3 border-b border-border px-4">
<Skeleton className="h-9 min-w-64 flex-1" />
<Skeleton className="h-9 w-32" />
<Skeleton className="h-9 w-36" />
<Skeleton className="h-9 w-24" />
<Skeleton className="h-9 w-28" />
</div>
<div className="flex h-[113px] flex-none border-b border-border">
<div className="flex min-w-0 flex-1 flex-col gap-2 border-r border-border px-4 py-3">
<Skeleton className="h-3 w-16" />
<div className="flex min-h-0 flex-1 gap-2">
<Skeleton className="h-full flex-1" />
<Skeleton className="h-full flex-1" />
<Skeleton className="h-full flex-1" />
</div>
</div>
<div className="flex min-w-0 flex-1 flex-col gap-2 bg-muted/30 px-4 py-3">
<Skeleton className="h-3 w-12" />
<div className="flex min-h-0 flex-1 gap-2">
<Skeleton className="h-full flex-1" />
<Skeleton className="h-full flex-1" />
<Skeleton className="h-full flex-1" />
</div>
</div>
</div>
<div className="flex min-h-0 flex-1">
<div className="min-w-0 flex-1 p-4">
{view === 'table' ? <TableSkeleton /> : <TreemapSkeleton />}
</div>
<div className="w-px flex-none bg-border" />
<aside className="flex w-1/5 flex-none flex-col gap-5 border-l border-border bg-muted p-4">
<Skeleton className="h-5 w-3/4" />
<Skeleton className="h-3 w-1/2" />
<Skeleton className="h-20 w-full" />
<Skeleton className="h-4 w-2/5" />
<Skeleton className="h-9 w-full" />
<Skeleton className="h-9 w-full" />
<Skeleton className="h-9 w-4/5" />
</aside>
</div>
</main>
)
}
......@@ -25,6 +25,7 @@
"polished": "^4.3.1",
"react": "19.2.0",
"react-dom": "19.2.0",
"react-virtuoso": "4.18.13",
"swr": "^2.2.4",
"tailwind-merge": "^2.5.5",
"tailwindcss-animate": "^1.0.7"
......
......@@ -694,6 +694,9 @@ importers:
react-dom:
specifier: npm:react-dom@19.3.0-canary-8b0da1c6-20260922
version: 19.3.0-canary-8b0da1c6-20260922(react@19.3.0-canary-8b0da1c6-20260922)
react-virtuoso:
specifier: 4.18.13
version: 4.18.13(react-dom@19.3.0-canary-8b0da1c6-20260922(react@19.3.0-canary-8b0da1c6-20260922))(react@19.3.0-canary-8b0da1c6-20260922)
swr:
specifier: ^2.2.4
version: 2.2.4(react@19.3.0-canary-8b0da1c6-20260922)
......@@ -16169,6 +16172,12 @@ packages:
react: ^15.3.0 || ^16.0.0-alpha
react-dom: ^15.3.0 || ^16.0.0-alpha
react-virtuoso@4.18.13:
resolution: {integrity: sha512-M4kP7zbV7JmLrnJYs0X2FBA8gnNlHisSYuKMyeJVYtWz31CAJeP57dgPJzfneUdKDKmL9SiqvcBQ32si8CfQSQ==}
peerDependencies:
react: '>=16 || >=17 || >= 18 || >= 19'
react-dom: '>=16 || >=17 || >= 18 || >=19'
react@0.0.0-experimental-8b0da1c6-20260922:
resolution: {integrity: sha512-6FfA5KzWk8kT+SM6IzWe8DlAj/iKvJ8LSD4jVyrm56kvvuzCPPe2pzhpseP1ZjdWdMnviq+S5/agjMEkIHlsyA==}
engines: {node: '>=0.10.0'}
......@@ -35623,6 +35632,11 @@ snapshots:
react-dom: 19.3.0-canary-8b0da1c6-20260922(react@19.3.0-canary-8b0da1c6-20260922)
react-lifecycles-compat: 3.0.4
react-virtuoso@4.18.13(react-dom@19.3.0-canary-8b0da1c6-20260922(react@19.3.0-canary-8b0da1c6-20260922))(react@19.3.0-canary-8b0da1c6-20260922):
dependencies:
react: 19.3.0-canary-8b0da1c6-20260922
react-dom: 19.3.0-canary-8b0da1c6-20260922(react@19.3.0-canary-8b0da1c6-20260922)
react@0.0.0-experimental-8b0da1c6-20260922: {}
react@19.3.0-canary-8b0da1c6-20260922: {}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment