Skip to content

Commit

Permalink
fix: Preload patch for Vite 5
Browse files Browse the repository at this point in the history
  • Loading branch information
rschristian committed Nov 19, 2023
1 parent 4f03892 commit 8468c1a
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/prerender.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,9 @@ export function PrerenderPlugin({
// Injects a window check into Vite's preload helper, instantly resolving
// the module rather than attempting to add a <link> to the document.
transform(code, id) {
if (id.endsWith(preloadHelperId)) {
// Vite keeps changing up the ID, best we can do for cross-version
// compat is an `includes`
if (id.includes(preloadHelperId)) {
const s = new MagicString(code);
s.replace(
`deps.length === 0`,
Expand Down

0 comments on commit 8468c1a

Please sign in to comment.