From 1de66560b6640a8f8fa74d45c593ad2afe192e01 Mon Sep 17 00:00:00 2001 From: Jordan Paulino Date: Thu, 16 Jul 2026 06:35:58 -0400 Subject: [PATCH] =?UTF-8?q?=F0=9F=8D=95=20vite:=20preload=20the=20view-mod?= =?UTF-8?q?e=20startup=20graph=20+=20on-page=20component=20chunks?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The Vite view bootstrap mounts components by scanning the DOM and import()-ing each component's client.js at runtime. Those dynamic chunks aren't referenced by any tag in the server-rendered HTML, so the browser can't start fetching a component's client (nav, header, …) or its deps (auth, gtm, shared chunks) until the deferred bootstrap has downloaded, executed, and called import() — a load waterfall that visibly delays JS-gated UI like the global nav. - buildManifest now keys dynamic entries (components//client, layouts//client), not just the bootstrap/kiln entries, so the server can look up a page's component chunks. - getViteModulePreloads now returns the bootstrap PLUS its static import chunks (globals-init, env-init, shared chunks) so the whole synchronous startup graph is preloaded during HTML parse. - new getComponentPreloads(names, assetPath) returns each component's client chunk + static imports (de-duped) for the server to merge into media.modulePreloads. Consumed by nymag/sites resolve-media.js (stacked PR). Docs: CLAY-VITE.md §4d. Tests: lib/cmd/vite/index.test.js, lib/cmd/vite/scripts.test.js. Co-authored-by: Cursor --- CLAY-VITE.md | 31 +++++++++- lib/cmd/vite/index.js | 107 +++++++++++++++++++++++++++++++---- lib/cmd/vite/index.test.js | 98 +++++++++++++++++++++++++++++++- lib/cmd/vite/scripts.js | 25 +++++++- lib/cmd/vite/scripts.test.js | 25 ++++++++ 5 files changed, 271 insertions(+), 15 deletions(-) diff --git a/CLAY-VITE.md b/CLAY-VITE.md index 271f8fe..b8272c2 100644 --- a/CLAY-VITE.md +++ b/CLAY-VITE.md @@ -384,6 +384,32 @@ flowchart TD `_manifest.json` is written → new path activates. Remove the flag → `_manifest.json` is absent on the next deploy → old path activates. No code changes needed in the site. +### 4d. Module preloading & the on-demand component waterfall + +View-mode pages inject **one** `