diff --git a/CLAY-VITE.md b/CLAY-VITE.md index 271f8fe..927c7c0 100644 --- a/CLAY-VITE.md +++ b/CLAY-VITE.md @@ -442,10 +442,42 @@ absent on the next deploy → old path activates. No code changes needed in the | Aspect | `clay compile` | `clay vite` | |---|---|---| | **How scripts are resolved** | `getDependencies()` reads `_registry.json` | `resolveModuleScripts()` reads `_manifest.json` | -| **Edit mode scripts** | All `_deps-*.js` + `_models-*.js` + `_kiln-*.js` + templates | Single `_kiln-edit-init` bundle + templates | +| **Edit mode scripts** | All `_deps-*.js` + `_models-*.js` + `_kiln-*.js` + templates | `vite-bootstrap-no-mount` + `_kiln-edit-init` bundle + templates | | **View mode scripts** | Numeric IDs → individual dep files | `vite-bootstrap` + `_globals-init` + shared chunks (typically 3–5 files) | +| **Component `client.js` in edit mode** | Never runs — the `edit` branch of `getDependencies()` ships no client bundle and no `_client-init.js` | Never runs — edit mode loads the no-mount bootstrap (see below) | | **Global scripts** | Individual files per registry entry (70–100 requests) | All `global/js/*.js` in one `_globals-init.js` (1 request) | +#### Component `client.js` does not run in edit mode + +Under `clay compile`, component controllers only ran on rendered pages: the `edit` branch of +`getDependencies()` resolves `model.js`, `kiln.js` and kiln plugins, but neither the client +dependency graph nor `_client-init.js` — the runtime that mounts controllers. Editors therefore +never executed component `client.js` inside Kiln. + +`clay vite` preserves that. Two bootstrap entries are generated from the same initializer prelude: + +| Entry | Loaded in | Contents | +|---|---|---| +| `.clay/vite-bootstrap.js` | view mode | prelude + `_clayClientModules` map + `mountComponentModules()` | +| `.clay/vite-bootstrap-no-mount.js` | edit mode | prelude only | + +The prelude (the `window.modules` stub, `_env-init.js`, `_globals-init.js` and the sticky-events +shim) is required in both modes — Kiln's preloader reads `window.modules`, and every `model.js` +and kiln plugin reads env through the object `_env-init.js` hydrates. Only the mount runtime is +view-mode-specific, and it runs at module scope, so serving the view bootstrap in edit mode +executes every on-page component's `client.js`. That fires analytics, ad calls (GPT injects an +`