Skip to content

Commit a9047c9

Browse files
authored
fix: qwikcity sw SSR prefetching (#7286)
1 parent 11e811d commit a9047c9

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

.changeset/tidy-years-smile.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@builder.io/qwik-city': patch
3+
---
4+
5+
FIX: some qrls weren't fetched correctly on page load

packages/qwik/src/server/prefetch-utils.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@ export function prefetchUrlsEventScript(base: string, prefetchResources: Prefetc
2424
bundles: flattenPrefetchResources(prefetchResources).map((u) => u.split('/').pop()!),
2525
};
2626
const args = JSON.stringify(['prefetch', base, ...data.bundles!]);
27-
return `(window.qwikPrefetchSW||(window.qwikPrefetchSW=[])).push(${args});`;
27+
28+
return `document.dispatchEvent(new CustomEvent("qprefetch",{detail:${JSON.stringify(data)}}));
29+
(window.qwikPrefetchSW||(window.qwikPrefetchSW=[])).push(${args});`;
2830
}
2931

3032
export function flattenPrefetchResources(prefetchResources: PrefetchResource[]) {

0 commit comments

Comments
 (0)