Skip to content

Commit 7f6fb7f

Browse files
committed
fix(qwik-city): correctly preload SPA bundles
1 parent 800d8b9 commit 7f6fb7f

File tree

3 files changed

+131
-112
lines changed

3 files changed

+131
-112
lines changed

packages/qwik-city/src/runtime/src/client-navigate.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,6 @@ export const prefetchSymbols = (path: string) => {
4545
if (isBrowser) {
4646
path = path.endsWith('/') ? path : path + '/';
4747
path = path.length > 1 && path.startsWith('/') ? path.slice(1) : path;
48-
preload(path);
48+
preload(path, 0.8);
4949
}
5050
};

packages/qwik/src/optimizer/src/plugins/bundle-graph.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,9 @@ export function convertManifestToBundleGraph(
5656
}
5757
// Routes etc
5858
if (bundleGraphAdders) {
59+
const combined = { ...manifest, bundles: graph };
5960
for (const adder of bundleGraphAdders) {
60-
const result = adder(manifest);
61+
const result = adder(combined);
6162
if (result) {
6263
Object.assign(graph, result);
6364
}
@@ -68,7 +69,17 @@ export function convertManifestToBundleGraph(
6869
for (const bundleName of Object.keys(graph)) {
6970
const bundle = graph[bundleName];
7071
const imports = bundle.imports?.filter((dep) => graph[dep]) || [];
71-
const dynamicImports = bundle.dynamicImports?.filter((dep) => graph[dep]?.symbols) || [];
72+
const dynamicImports =
73+
bundle.dynamicImports?.filter(
74+
// we only want to include dynamic imports that belong to the app
75+
// e.g. not all languages supported by shiki
76+
(dep) =>
77+
graph[dep] &&
78+
// either there are qrls
79+
(graph[dep].symbols ||
80+
// or it's a dynamic import from the app source
81+
graph[dep].origins?.some((o) => !o.includes('node_modules')))
82+
) || [];
7283

7384
/**
7485
* Overwrite so we don't mutate the given objects. Be sure to copy all properties we use during

0 commit comments

Comments
 (0)