droboticflow-new/scripts/lib/frontend-chunking.mjs
d-robotics da446d13b5 ⚡ Fix slow page loading: static gzip, list pagination, auth cache, dashboard aggregation, video direct link
- C1/S3: build-time precompressed .gz served by spaHandler (writeBundle plugin), motion-vendor chunk rule fix
- C3/S1: /api/runs default cursor pagination (byte-compatible), /api/human-items limit/cursor + Mongo projection + filter pushdown
- C2/S5: in-process principal TTL cache (45s) with full invalidation paths; /api/users limit+q with org isolation
- C4/S2: dashboard counter pushdown ($group/CountDocuments), 45s response/snapshot caches, production stats snapshot cache
- C5: BOS presigned direct-link video preview (307) with background pre-transcode, /tmp cache TTL+LRU, gzip bypass, sync=1 rollback
- S4/S6: POC readiness point queries, human-batches GET no longer writes (60s sweeper), admin ops page N+1 fan-out removed
- Fixes found en route: BSON cursor self-reference recursion, backfill loop cursor advance, supplier cascade session flush
- Frontend: nextCursor passthrough (human-loop/users), acceptance pool no longer truncated at 500

Co-authored-by: AgentTeams slow-page-fix
2026-10-09 17:45:27 -07:00

36 lines
1.1 KiB
JavaScript

export function frontendManualChunk(id = "") {
if (!id.includes("node_modules")) {
return undefined;
}
if (id.includes("reactflow") || id.includes("dagre")) {
return "workflow-vendor";
}
// Recharts is only reachable from the lazily loaded ResourceUsageChart.
// Let Rollup keep it with that dynamic graph instead of promoting a
// charts-vendor dependency into the application entry chunk.
if (id.includes("recharts")) {
return undefined;
}
// motion is only reachable from lazily loaded pages (WorkflowEditor,
// Monitoring, Audit, Runs). Pinning it into a manual chunk promotes the
// package plus hoisted react interop modules into the application entry
// chunk via modulepreload. Let Rollup keep it inside the dynamic graph so
// it is only fetched when one of those pages loads.
if (id.includes("/motion/")) {
return undefined;
}
if (id.includes("lucide-react")) {
return "icons-vendor";
}
if (id.includes("react-router-dom") || id.includes("/react-dom/") || id.includes("/react/")) {
return "react-vendor";
}
return undefined;
}