Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: refactor client build data #9699

Merged
merged 1 commit into from
Apr 18, 2023
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
17 changes: 5 additions & 12 deletions packages/kit/src/exports/vite/dev/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,18 +115,11 @@ export async function dev(vite, vite_config, svelte_config) {
mimeTypes: get_mime_lookup(manifest_data),
_: {
client: {
start: {
file: `${runtime_base}/client/start.js`,
imports: [],
stylesheets: [],
fonts: []
},
app: {
file: `${svelte_config.kit.outDir}/generated/client/app.js`,
imports: [],
stylesheets: [],
fonts: []
}
start: `${runtime_base}/client/start.js`,
app: `${svelte_config.kit.outDir}/generated/client/app.js`,
imports: [],
stylesheets: [],
fonts: []
},
nodes: manifest_data.nodes.map((node, index) => {
return async () => {
Expand Down
20 changes: 10 additions & 10 deletions packages/kit/src/exports/vite/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -726,17 +726,17 @@ function kit({ svelte_config }) {
/** @type {import('vite').Manifest} */
const client_manifest = JSON.parse(read(`${out}/client/${vite_config.build.manifest}`));

const deps_of = /** @param {string} f */ (f) =>
find_deps(client_manifest, posixify(path.relative('.', f)), false);
const start = deps_of(`${runtime_directory}/client/start.js`);
const app = deps_of(`${kit.outDir}/generated/client-optimized/app.js`);

build_data.client = {
start: find_deps(
client_manifest,
posixify(path.relative('.', `${runtime_directory}/client/start.js`)),
false
),
app: find_deps(
client_manifest,
posixify(path.relative('.', `${kit.outDir}/generated/client-optimized/app.js`)),
false
)
start: start.file,
app: app.file,
imports: [...start.imports, ...app.imports],
stylesheets: [...start.stylesheets, ...app.stylesheets],
fonts: [...start.fonts, ...app.fonts]
};

const css = output.filter(
Expand Down
10 changes: 5 additions & 5 deletions packages/kit/src/runtime/server/page/render.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,9 @@ export async function render_response({

const { client } = manifest._;

const modulepreloads = new Set([...client.start.imports, ...client.app.imports]);
const stylesheets = new Set(client.app.stylesheets);
const fonts = new Set(client.app.fonts);
const modulepreloads = new Set(client.imports);
const stylesheets = new Set(client.stylesheets);
const fonts = new Set(client.fonts);

/** @type {Set<string>} */
const link_header_preloads = new Set();
Expand Down Expand Up @@ -356,8 +356,8 @@ export async function render_response({
}

blocks.push(`Promise.all([
import(${s(prefixed(client.start.file))}),
import(${s(prefixed(client.app.file))})
import(${s(prefixed(client.start))}),
import(${s(prefixed(client.app))})
]).then(([kit, app]) => {
kit.start(${args.join(', ')});
});`);
Expand Down
7 changes: 2 additions & 5 deletions packages/kit/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {
RouteSegment,
UniqueInterface
} from './private.js';
import { AssetDependencies, SSRNodeLoader, SSRRoute, ValidatedConfig } from './internal.js';
import { BuildData, SSRNodeLoader, SSRRoute, ValidatedConfig } from './internal.js';

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

Expand Down Expand Up @@ -1059,10 +1059,7 @@ export interface SSRManifest {

/** private fields */
_: {
client: {
start: AssetDependencies;
app: AssetDependencies;
};
client: NonNullable<BuildData['client']>;
nodes: SSRNodeLoader[];
routes: SSRRoute[];
matchers(): Promise<Record<string, ParamMatcher>>;
Expand Down
8 changes: 5 additions & 3 deletions packages/kit/types/internal.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import {
ResolveOptions,
Server,
ServerInitOptions,
SSRManifest,
HandleFetch,
Actions,
HandleClientError
Expand Down Expand Up @@ -55,8 +54,11 @@ export interface BuildData {
manifest_data: ManifestData;
service_worker: string | null;
client: {
start: AssetDependencies;
app: AssetDependencies;
start: string;
app: string;
imports: string[];
stylesheets: string[];
fonts: string[];
} | null;
server_manifest: import('vite').Manifest;
}
Expand Down