Skip to content

Commit c2b3df7

Browse files
authored
chore: refactor client build data (#9699)
1 parent 0ff6dcd commit c2b3df7

File tree

5 files changed

+27
-35
lines changed

5 files changed

+27
-35
lines changed

packages/kit/src/exports/vite/dev/index.js

+5-12
Original file line numberDiff line numberDiff line change
@@ -115,18 +115,11 @@ export async function dev(vite, vite_config, svelte_config) {
115115
mimeTypes: get_mime_lookup(manifest_data),
116116
_: {
117117
client: {
118-
start: {
119-
file: `${runtime_base}/client/start.js`,
120-
imports: [],
121-
stylesheets: [],
122-
fonts: []
123-
},
124-
app: {
125-
file: `${svelte_config.kit.outDir}/generated/client/app.js`,
126-
imports: [],
127-
stylesheets: [],
128-
fonts: []
129-
}
118+
start: `${runtime_base}/client/start.js`,
119+
app: `${svelte_config.kit.outDir}/generated/client/app.js`,
120+
imports: [],
121+
stylesheets: [],
122+
fonts: []
130123
},
131124
nodes: manifest_data.nodes.map((node, index) => {
132125
return async () => {

packages/kit/src/exports/vite/index.js

+10-10
Original file line numberDiff line numberDiff line change
@@ -726,17 +726,17 @@ function kit({ svelte_config }) {
726726
/** @type {import('vite').Manifest} */
727727
const client_manifest = JSON.parse(read(`${out}/client/${vite_config.build.manifest}`));
728728

729+
const deps_of = /** @param {string} f */ (f) =>
730+
find_deps(client_manifest, posixify(path.relative('.', f)), false);
731+
const start = deps_of(`${runtime_directory}/client/start.js`);
732+
const app = deps_of(`${kit.outDir}/generated/client-optimized/app.js`);
733+
729734
build_data.client = {
730-
start: find_deps(
731-
client_manifest,
732-
posixify(path.relative('.', `${runtime_directory}/client/start.js`)),
733-
false
734-
),
735-
app: find_deps(
736-
client_manifest,
737-
posixify(path.relative('.', `${kit.outDir}/generated/client-optimized/app.js`)),
738-
false
739-
)
735+
start: start.file,
736+
app: app.file,
737+
imports: [...start.imports, ...app.imports],
738+
stylesheets: [...start.stylesheets, ...app.stylesheets],
739+
fonts: [...start.fonts, ...app.fonts]
740740
};
741741

742742
const css = output.filter(

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

+5-5
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,9 @@ export async function render_response({
6363

6464
const { client } = manifest._;
6565

66-
const modulepreloads = new Set([...client.start.imports, ...client.app.imports]);
67-
const stylesheets = new Set(client.app.stylesheets);
68-
const fonts = new Set(client.app.fonts);
66+
const modulepreloads = new Set(client.imports);
67+
const stylesheets = new Set(client.stylesheets);
68+
const fonts = new Set(client.fonts);
6969

7070
/** @type {Set<string>} */
7171
const link_header_preloads = new Set();
@@ -356,8 +356,8 @@ export async function render_response({
356356
}
357357

358358
blocks.push(`Promise.all([
359-
import(${s(prefixed(client.start.file))}),
360-
import(${s(prefixed(client.app.file))})
359+
import(${s(prefixed(client.start))}),
360+
import(${s(prefixed(client.app))})
361361
]).then(([kit, app]) => {
362362
kit.start(${args.join(', ')});
363363
});`);

packages/kit/types/index.d.ts

+2-5
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import {
1818
RouteSegment,
1919
UniqueInterface
2020
} from './private.js';
21-
import { AssetDependencies, SSRNodeLoader, SSRRoute, ValidatedConfig } from './internal.js';
21+
import { BuildData, SSRNodeLoader, SSRRoute, ValidatedConfig } from './internal.js';
2222

2323
export { PrerenderOption } from './private.js';
2424

@@ -1059,10 +1059,7 @@ export interface SSRManifest {
10591059

10601060
/** private fields */
10611061
_: {
1062-
client: {
1063-
start: AssetDependencies;
1064-
app: AssetDependencies;
1065-
};
1062+
client: NonNullable<BuildData['client']>;
10661063
nodes: SSRNodeLoader[];
10671064
routes: SSRRoute[];
10681065
matchers(): Promise<Record<string, ParamMatcher>>;

packages/kit/types/internal.d.ts

+5-3
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import {
1010
ResolveOptions,
1111
Server,
1212
ServerInitOptions,
13-
SSRManifest,
1413
HandleFetch,
1514
Actions,
1615
HandleClientError
@@ -55,8 +54,11 @@ export interface BuildData {
5554
manifest_data: ManifestData;
5655
service_worker: string | null;
5756
client: {
58-
start: AssetDependencies;
59-
app: AssetDependencies;
57+
start: string;
58+
app: string;
59+
imports: string[];
60+
stylesheets: string[];
61+
fonts: string[];
6062
} | null;
6163
server_manifest: import('vite').Manifest;
6264
}

0 commit comments

Comments
 (0)