Skip to content

Commit 75efd88

Browse files
authored
chore: fix type and add docs (#13545)
1 parent 3fdb664 commit 75efd88

File tree

3 files changed

+27
-12
lines changed

3 files changed

+27
-12
lines changed

packages/kit/src/runtime/server/page/render.js

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -116,19 +116,22 @@ export async function render_response({
116116
}
117117

118118
if (page_config.ssr) {
119-
if (__SVELTEKIT_DEV__ && !branch.at(-1)?.node.component) {
120-
// Can only be the leaf, layouts have a fallback component generated
121-
throw new Error(`Missing +page.svelte component for route ${event.route.id}`);
122-
}
123-
124119
/** @type {Record<string, any>} */
125120
const props = {
126121
stores: {
127122
page: writable(null),
128123
navigating: writable(null),
129124
updated
130125
},
131-
constructors: await Promise.all(branch.map(({ node }) => node.component())),
126+
constructors: await Promise.all(
127+
branch.map(({ node }) => {
128+
if (!node.component) {
129+
// Can only be the leaf, layouts have a fallback component generated
130+
throw new Error(`Missing +page.svelte component for route ${event.route.id}`);
131+
}
132+
return node.component();
133+
})
134+
),
132135
form: form_value
133136
};
134137

packages/kit/src/types/internal.d.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,6 @@ export interface ServerNode {
386386
}
387387

388388
export interface SSRNode {
389-
component: SSRComponentLoader;
390389
/** index into the `nodes` array in the generated `client/app.js`. */
391390
index: number;
392391
/** external JS files that are loaded on the client. `imports[0]` is the entry point (e.g. `client/nodes/0.js`) */
@@ -395,12 +394,17 @@ export interface SSRNode {
395394
stylesheets: string[];
396395
/** external font files that are loaded on the client */
397396
fonts: string[];
398-
/** inlined styles. */
399-
inline_styles?(): MaybePromise<Record<string, string>>;
400397

401398
universal_id?: string;
402399
server_id?: string;
400+
401+
/** inlined styles. */
402+
inline_styles?(): MaybePromise<Record<string, string>>;
403+
/** Svelte component */
404+
component?: SSRComponentLoader;
405+
/** +page.js or +layout.js */
403406
universal?: UniversalNode;
407+
/** +page.server.js, +layout.server.js, or +server.js */
404408
server?: ServerNode;
405409
}
406410

@@ -484,6 +488,10 @@ export interface SSRState {
484488
*/
485489
prerender_default?: PrerenderOption;
486490
read?: (file: string) => Buffer;
491+
/**
492+
* Used to setup `__SVELTEKIT_TRACK__` which checks if a used feature is supported.
493+
* E.g. if `read` from `$app/server` is used, it checks whether the route's config is compatible.
494+
*/
487495
before_handle?: (event: RequestEvent, config: any, prerender: PrerenderOption) => void;
488496
emulator?: Emulator;
489497
}

packages/kit/types/index.d.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1864,7 +1864,6 @@ declare module '@sveltejs/kit' {
18641864
}
18651865

18661866
interface SSRNode {
1867-
component: SSRComponentLoader;
18681867
/** index into the `nodes` array in the generated `client/app.js`. */
18691868
index: number;
18701869
/** external JS files that are loaded on the client. `imports[0]` is the entry point (e.g. `client/nodes/0.js`) */
@@ -1873,12 +1872,17 @@ declare module '@sveltejs/kit' {
18731872
stylesheets: string[];
18741873
/** external font files that are loaded on the client */
18751874
fonts: string[];
1876-
/** inlined styles. */
1877-
inline_styles?(): MaybePromise<Record<string, string>>;
18781875

18791876
universal_id?: string;
18801877
server_id?: string;
1878+
1879+
/** inlined styles. */
1880+
inline_styles?(): MaybePromise<Record<string, string>>;
1881+
/** Svelte component */
1882+
component?: SSRComponentLoader;
1883+
/** +page.js or +layout.js */
18811884
universal?: UniversalNode;
1885+
/** +page.server.js, +layout.server.js, or +server.js */
18821886
server?: ServerNode;
18831887
}
18841888

0 commit comments

Comments
 (0)