🍕 Improve Vite mount error diagnostics and docs#251
Merged
Conversation
Several places in CLAY-VITE.md and BUNDLER-COMPARISON.md described the legacy Browserify component loader as "mounts every .client module loaded — no DOM check" or "DOM or not". That overstates what _client-init.js actually does. Per lib/cmd/compile/_client-init.js, mountComponentModules() iterates every .client key in window.modules and calls window.require(key) on each — which executes the module body and walks its dependency graph regardless of DOM presence — but the exported controller function is only invoked via tryToMount() for elements matching the [data-uri*="_components/<name>/"] / [data-uri$="_components<name>"] selectors. So the mount call itself IS DOM-gated; what isn't gated is module evaluation. The Vite improvement is therefore narrower but still real: vite-bootstrap scans the DOM first and skips the dynamic import() entirely if no matching element exists, so neither the module body nor any of its transitive dependencies execute. Updated all four prose locations to reflect this; the mermaid diagrams already used the more precise "calls window.require(key) for every .client / regardless of DOM presence" wording and were left as-is. Co-authored-by: Cursor <cursoragent@cursor.com>
Emit structured preload/load/mount error details in the generated Vite bootstrap and document concrete console output so developers can quickly identify failing component phases, URIs, and stack context. Co-authored-by: Cursor <cursoragent@cursor.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
vite-bootstrap.jsforpreload,load,mount, andds-mountphasescomponent,moduleKey,uri,message,stack, and nestedcause)CLAY-VITE.mdwith concrete example browser console output so failures are easier to debug quicklyWhy
The previous mount error output only exposed terse messages and made it hard to identify where/why a component failed. This change surfaces enough context for engineers to debug directly from DevTools without digging through generated bundles.
Before vs after output
Before
After
Test plan
npx jest lib/cmd/vite/generators.test.js