Skip to content

Commit 57e3724

Browse files
committed
new manifest implementation
1 parent 4afe460 commit 57e3724

22 files changed

Lines changed: 648 additions & 562 deletions

packages/start-vinxi/src/server/pageEvent.ts

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,24 @@
11
import { getCookie, setCookie } from "vinxi/http";
22
import { createRoutes } from "../router/FileRoutes";
3-
import { FetchEvent, PageEvent } from "./types";
3+
import type { FetchEvent, PageEvent } from "./types";
44

55
function initFromFlash(ctx: FetchEvent) {
66
const flash = getCookie(ctx.nativeEvent, "flash");
77
if (!flash) return;
88
try {
9-
let param = JSON.parse(flash);
9+
const param = JSON.parse(flash);
1010
if (!param || !param.result) return;
11-
const input = [...param.input.slice(0, -1), new Map(param.input[param.input.length - 1])];
11+
const input = [
12+
...param.input.slice(0, -1),
13+
new Map(param.input[param.input.length - 1]),
14+
];
1215
const result = param.error ? new Error(param.result) : param.result;
1316
return {
1417
input,
1518
url: param.url,
1619
pending: false,
1720
result: param.thrown ? undefined : result,
18-
error: param.thrown ? result : undefined
21+
error: param.thrown ? result : undefined,
1922
};
2023
} catch (e) {
2124
console.error(e);
@@ -38,20 +41,20 @@ export async function createPageEvent(ctx: FetchEvent) {
3841
? await clientManifest.inputs[import.meta.env.START_APP]!.assets()
3942
: []),
4043
...(import.meta.env.START_ISLANDS
41-
? (await serverManifest.inputs[serverManifest.handler]!.assets()).filter(
42-
s => (s as any).attrs.rel !== "modulepreload"
43-
)
44-
: [])
44+
? (
45+
await serverManifest.inputs[serverManifest.handler]!.assets()
46+
).filter((s) => (s as any).attrs.rel !== "modulepreload")
47+
: []),
4548
],
4649
router: {
47-
submission: initFromFlash(ctx) as any
50+
submission: initFromFlash(ctx) as any,
4851
},
4952
routes: createRoutes(),
5053
// prevUrl: prevPath || "",
5154
// mutation: mutation,
5255
// $type: FETCH_EVENT,
5356
complete: false,
54-
$islands: new Set<string>()
57+
$islands: new Set<string>(),
5558
});
5659

5760
return pageEvent;

packages/start/src/client/StartClient.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
// @refresh skip
2-
// @ts-ignore
3-
import "./client-manifest.js";
42
import App from "#start/app";
53
import type { JSX } from "solid-js";
64
import { ErrorBoundary } from "../shared/ErrorBoundary.jsx";

packages/start/src/client/client-manifest.ts

Lines changed: 0 additions & 66 deletions
This file was deleted.

packages/start/src/config/fs-routes/index.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import { relative } from "node:path";
22
import type { PluginOption, ResolvedConfig } from "vite";
3-
import { manifest } from "./manifest.js";
43
import type { BaseFileSystemRouter } from "./router.js";
54
import { treeShake } from "./tree-shake.js";
65

6+
const getClientManifestPath = new URL("../../server/manifest/client-manifest.js", import.meta.url).pathname;
7+
78
export const moduleId = "solid-start:routes";
89

910
export type RouterBuilder = (config: ResolvedConfig) => BaseFileSystemRouter;
@@ -20,7 +21,6 @@ export function fsRoutes({
2021
(globalThis as any).ROUTERS = {};
2122

2223
return [
23-
manifest(handlers),
2424
{
2525
name: "solid-start-fs-routes",
2626
enforce: "pre",
@@ -82,8 +82,9 @@ ${js.getImportStatements()}
8282
${this.environment.name === "server"
8383
? ""
8484
: `
85+
import { getClientManifest } from "${getClientManifestPath}"
8586
function clientManifestImport(id) {
86-
return import(/* @vite-ignore */ globalThis.MANIFEST.inputs[id].output.path)
87+
return getClientManifest().import(id)
8788
}`
8889
}
8990
export default ${routesCode}`;

0 commit comments

Comments
 (0)