Skip to content

Commit

Permalink
fix: qwikcity sw SSR prefetching (#7286)
Browse files Browse the repository at this point in the history
  • Loading branch information
shairez authored Jan 27, 2025
1 parent 11e811d commit a9047c9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/tidy-years-smile.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@builder.io/qwik-city': patch
---

FIX: some qrls weren't fetched correctly on page load
4 changes: 3 additions & 1 deletion packages/qwik/src/server/prefetch-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ export function prefetchUrlsEventScript(base: string, prefetchResources: Prefetc
bundles: flattenPrefetchResources(prefetchResources).map((u) => u.split('/').pop()!),
};
const args = JSON.stringify(['prefetch', base, ...data.bundles!]);
return `(window.qwikPrefetchSW||(window.qwikPrefetchSW=[])).push(${args});`;

return `document.dispatchEvent(new CustomEvent("qprefetch",{detail:${JSON.stringify(data)}}));
(window.qwikPrefetchSW||(window.qwikPrefetchSW=[])).push(${args});`;
}

export function flattenPrefetchResources(prefetchResources: PrefetchResource[]) {
Expand Down

0 comments on commit a9047c9

Please sign in to comment.