Repository navigation
fix: Define hashed __VITE_PRELOAD__ markers when prerendering (Vite 8.4+) - #44
Closed
JoviDeCroock wants to merge 1 commit into
Closed
JoviDeCroock wants to merge 1 commit into
JoviDeCroock wants to merge 1 commit into
Conversation
Vite 8.4.0 can suffix the preload marker with a hash (`__VITE_PRELOAD__<hash>`). The marker is still present in chunks during `generateBundle`, so prerendering any dynamic import threw a ReferenceError. Found and fixed with AI assistance (Claude Code). Co-Authored-By: Claude <noreply@anthropic.com>
Member
|
I'm not sure a single word of that description was written by you; you have a really prominent voice when you actually write yourself (which is good!) and this just ain't it. I shouldn't have to point at the CoC, but...
If you want to drop the AI and then suggest a change, I'm open, but I'm going to keep ownership over this repo and something like this:
will be an insta-close going forward. I'll update the policy for this repo when I can. Equally, it can be moved back to my name as well. |
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.
Vite 8.4.0 changed the dynamic-import preload marker from
__VITE_PRELOAD__to__VITE_PRELOAD__<32-hex hash>(seepreloadMarkerREin Vite'simportAnalysisBuild). The marker is still in the chunk code when this plugin'sgenerateBundleimports the bundle in Node. We only defineglobalThis.__VITE_PRELOAD__, so any dynamic import that runs during prerender throws:That covers
preact-iso's ownprerender(), which doesimport('./prerender.js'), so the unmodifiedcreate-preactprerender + router template fails to build onvite@8.4.x. It builds onvite@8.3.1.Fix: while writing chunks to the temp dir, define every hashed marker found in the chunk code as
[], the same as the existing__VITE_PRELOAD__shim. The code isn't rewritten, so source-map error positions stay correct.