From 0499779f1f7e1b4298b29bb3d2886695257ae8f0 Mon Sep 17 00:00:00 2001 From: Ryan Carniato Date: Tue, 21 May 2024 09:03:31 -0700 Subject: [PATCH] fix single flight in ssr false --- .changeset/dry-shrimps-repeat.md | 5 +++++ packages/start/config/fs-router.js | 12 ++++++++---- packages/start/src/router/FileRoutes.ts | 2 +- packages/start/src/router/routes.ts | 3 ++- 4 files changed, 16 insertions(+), 6 deletions(-) create mode 100644 .changeset/dry-shrimps-repeat.md diff --git a/.changeset/dry-shrimps-repeat.md b/.changeset/dry-shrimps-repeat.md new file mode 100644 index 000000000..121697101 --- /dev/null +++ b/.changeset/dry-shrimps-repeat.md @@ -0,0 +1,5 @@ +--- +"@solidjs/start": patch +--- + +fix single flight in ssr false diff --git a/packages/start/config/fs-router.js b/packages/start/config/fs-router.js index 206c25af4..994c49a1c 100644 --- a/packages/start/config/fs-router.js +++ b/packages/start/config/fs-router.js @@ -24,6 +24,7 @@ export class SolidStartClientFileRouter extends BaseFileSystemRouter { if (src.endsWith(".md") || src.endsWith(".mdx")) { return { + page: true, $component: { src: src, pick: ["$css"] @@ -35,10 +36,11 @@ export class SolidStartClientFileRouter extends BaseFileSystemRouter { } const [_, exports] = analyzeModule(src); - const hasDefault = exports.find(e => e.n === "default"); - const hasRouteConfig = exports.find(e => e.n === "route"); + const hasDefault = !!exports.find(e => e.n === "default"); + const hasRouteConfig = !!exports.find(e => e.n === "route"); if (hasDefault) { return { + page: true, $component: { src: src, pick: ["default", "$css"] @@ -93,6 +95,7 @@ export class SolidStartServerFileRouter extends BaseFileSystemRouter { let path = this.toPath(src); if (src.endsWith(".md") || src.endsWith(".mdx")) { return { + page: true, $component: { src: src, pick: ["$css"] @@ -105,10 +108,11 @@ export class SolidStartServerFileRouter extends BaseFileSystemRouter { const [_, exports] = analyzeModule(src); const hasRouteConfig = exports.find(e => e.n === "route"); - const hasDefault = exports.find(e => e.n === "default"); - const hasAPIRoutes = exports.find(exp => HTTP_METHODS.includes(exp.n)); + const hasDefault = !!exports.find(e => e.n === "default"); + const hasAPIRoutes = !!exports.find(exp => HTTP_METHODS.includes(exp.n)); if (hasDefault || hasAPIRoutes) { return { + page: hasDefault, $component: !this.config.dataOnly && hasDefault ? { diff --git a/packages/start/src/router/FileRoutes.ts b/packages/start/src/router/FileRoutes.ts index 8dde669dd..b9ab8f833 100644 --- a/packages/start/src/router/FileRoutes.ts +++ b/packages/start/src/router/FileRoutes.ts @@ -14,7 +14,7 @@ export function createRoutes() { ...(route.$$route ? route.$$route.require().route.info : {}), filesystem: true }, - component: lazyRoute( + component: route.$component && lazyRoute( route.$component, import.meta.env.START_ISLANDS ? import.meta.env.MANIFEST["ssr"] diff --git a/packages/start/src/router/routes.ts b/packages/start/src/router/routes.ts index 0a907dcc9..14269357e 100644 --- a/packages/start/src/router/routes.ts +++ b/packages/start/src/router/routes.ts @@ -5,6 +5,7 @@ interface Route { path: string; id: string; children?: Route[]; + page?: boolean; $component?: any; $GET?: any; $POST?: any; @@ -23,7 +24,7 @@ declare module "vinxi/routes" { } export const pageRoutes = defineRoutes( - (fileRoutes as unknown as Route[]).filter(o => o.$component) + (fileRoutes as unknown as Route[]).filter(o => o.page) ); function defineRoutes(fileRoutes: Route[]) {