Skip to content

🐛 Share Vite singleton across all resolution keys#534

Merged
retlehs merged 1 commit intomainfrom
vite-singleton-binding
Apr 26, 2026
Merged

🐛 Share Vite singleton across all resolution keys#534
retlehs merged 1 commit intomainfrom
vite-singleton-binding

Conversation

@retlehs
Copy link
Copy Markdown
Member

@retlehs retlehs commented Apr 26, 2026

Summary

Vite::useCspNonce() (and any other state set via the Vite facade — useIntegrityKey, prefetch, macros, etc.) was silently dropped before reaching @vite-rendered tags.

Cause

AssetsServiceProvider bound only the string key 'assets.vite' as a singleton, with Roots\Acorn\Assets\Vite as its concrete. Illuminate\Foundation\Vite::class was aliased to Vite::class, but Vite::class itself had no binding — so resolving it (or its alias) auto-resolved a fresh instance each time. The Vite facade resolves Foundation\Vite::class, so the nonce was set on a throwaway instance and @vite rendered against a different one.

Fix

Bind Roots\Acorn\Assets\Vite as the singleton, and alias both 'assets.vite' and Illuminate\Foundation\Vite::class to it. All three keys now share one instance.

Fixes #533

🤖 Generated with Claude Code

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>
@retlehs retlehs self-assigned this Apr 26, 2026
@retlehs retlehs merged commit 2bb7549 into main Apr 26, 2026
2 of 5 checks passed
@retlehs retlehs deleted the vite-singleton-binding branch April 26, 2026 23:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Vite::useCspNonce() has no effect on @vite rendered tags

1 participant