🐛 Share Vite singleton across all resolution keys#534
Merged
Conversation
Bind Roots\Acorn\Assets\Vite as the singleton and alias both 'assets.vite' and Illuminate\Foundation\Vite to it, so all three resolution keys share one instance. Previously only 'assets.vite' was shared; resolving Foundation\Vite (what the Vite facade and @Vite directive use) returned a fresh instance each time, silently dropping useCspNonce(), useIntegrityKey(), prefetch(), and any other state set on the facade. Closes #533 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.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::useCspNonce()(and any other state set via theVitefacade —useIntegrityKey,prefetch, macros, etc.) was silently dropped before reaching@vite-rendered tags.Cause
AssetsServiceProviderbound only the string key'assets.vite'as a singleton, withRoots\Acorn\Assets\Viteas its concrete.Illuminate\Foundation\Vite::classwas aliased toVite::class, butVite::classitself had no binding — so resolving it (or its alias) auto-resolved a fresh instance each time. TheVitefacade resolvesFoundation\Vite::class, so the nonce was set on a throwaway instance and@viterendered against a different one.Fix
Bind
Roots\Acorn\Assets\Viteas the singleton, and alias both'assets.vite'andIlluminate\Foundation\Vite::classto it. All three keys now share one instance.Fixes #533
🤖 Generated with Claude Code