Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions apps/web/tests/build.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,9 @@ beforeAll(async () => {
return [...keys].map((each) => chunks[each].file);
};

// Node 0 is the root layout, which every page renders.
initialLoad = new Set([...manifest.client.imports, ...nodeScripts(0)]);
// Node 0 is the root layout, which every page renders, and node 1 the root error page, which the
// client loads on every page before it hydrates.
initialLoad = new Set([...manifest.client.imports, ...nodeScripts(0), ...nodeScripts(1)]);

routes = manifest.routes.flatMap(({ id, page }) => {
if (!page) return [];
Expand Down Expand Up @@ -92,8 +93,8 @@ it('ships no sourcemaps to the browser', () => {
// that needs more than that is worth deciding on, not finding here later.

it('keeps what every page loads within its budget', () => {
// The entry and the root layout with everything they import: SvelteKit's and Svelte's runtimes,
// devalue, and the small components pages share (vite.config.ts). About 172 KiB.
// The entry, the root layout and the root error page with everything they import: SvelteKit's and
// Svelte's runtimes, devalue, and the small components pages share (vite.config.ts). About 179 KiB.
expect(size(initialLoad)).toBeLessThan(180 * 1024);
});

Expand Down
15 changes: 15 additions & 0 deletions patches/@sveltejs__kit@3.1.0.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
diff --git a/src/runtime/server/page/render.js b/src/runtime/server/page/render.js
index 0a8042eb03fa01a378517d8b5ef48891438122be..6106bfd9b62b535f1de568ab913302c530f6d1d6 100644
--- a/src/runtime/server/page/render.js
+++ b/src/runtime/server/page/render.js
@@ -367,6 +367,10 @@ export async function render_response({
}

if (!client.inline) {
+ // The client awaits the root error page before it hydrates (`start` in client.js), so preload
+ // its JS too, or the browser only finds it after start.js has run (sveltejs/kit#17415).
+ for (const url of (await manifest.nodes[1]()).imports) modulepreloads.add(url);
+
for (const dep of modulepreloads) {
const path = prefixed(dep);

11 changes: 6 additions & 5 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions pnpm-workspace.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,11 @@ overrides:
# release has the fix (#6214).
patchedDependencies:
'@stryker-mutator/vitest-runner@10.0.0': patches/@stryker-mutator__vitest-runner@10.0.0.patch
# SvelteKit's client imports the root error page before it hydrates, but the server doesn't
# preload it, so every page fetched it a round trip late (sveltejs/kit#17415). That round trip put
# /projects/halflight's simulated LCP over Lighthouse's budget on a busy machine. Drop the patch
# once a release has the fix (sveltejs/kit#17416).
'@sveltejs/kit@3.1.0': patches/@sveltejs__kit@3.1.0.patch
# zod 3.x reaches prod only through @atproto/* (^3.23.8), and no 3.x release has the fix (4.6.6
# does). Drop this once @atproto moves to zod 4.
auditConfig:
Expand Down
Loading