From b264075384663f9fdaa0af6800d2b5cf4ba91195 Mon Sep 17 00:00:00 2001 From: Julian Cataldo Date: Sat, 21 Dec 2024 23:13:52 +0100 Subject: [PATCH] fix: vite 6 typings somehow requires to return explicit plugin type for factories --- packages/engine/src/vite/build-routes.ts | 16 ++++++++++++---- packages/engine/src/vite/html-routes.ts | 4 ++-- packages/engine/src/vite/virtual-routes.ts | 4 ++-- 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/packages/engine/src/vite/build-routes.ts b/packages/engine/src/vite/build-routes.ts index b990167..525b796 100644 --- a/packages/engine/src/vite/build-routes.ts +++ b/packages/engine/src/vite/build-routes.ts @@ -2,7 +2,10 @@ import { basename, extname, join } from 'node:path'; import { createFilter, type Plugin, type ViteDevServer } from 'vite'; -import { renderRoutes } from '../routes/render.js'; +import { + renderRoutes, + type RenderedRouteDefinition, +} from '../routes/render.js'; import { REGEX_TAG_LINK, REGEX_TAG_SCRIPT } from '../render/route-template.js'; import type { RoutesManifest } from '../routes/route.js'; import type { GracileConfig } from '../user-config.js'; @@ -26,7 +29,12 @@ export const buildRoutes = async ({ root: string; gracileConfig: GracileConfig; serverMode?: boolean; -}) => { +}): Promise<{ + routes: RoutesManifest; + renderedRoutes: RenderedRouteDefinition[]; + inputList: string[]; + plugin: Plugin[]; +}> => { // TODO: extract upstream, return just the plugins const { renderedRoutes } = await renderRoutes({ vite: viteServerForBuild, @@ -103,7 +111,7 @@ export const buildRoutes = async ({ return null; }, - } satisfies Plugin, + }, { name: 'gracile-collect-handler-assets', @@ -180,7 +188,7 @@ export const buildRoutes = async ({ } } }, - } satisfies Plugin, + }, ], }; }; diff --git a/packages/engine/src/vite/html-routes.ts b/packages/engine/src/vite/html-routes.ts index 22d1290..a01ad63 100644 --- a/packages/engine/src/vite/html-routes.ts +++ b/packages/engine/src/vite/html-routes.ts @@ -7,7 +7,7 @@ import type { Plugin } from 'vite'; * but not THAT useful. * @todo Make tests and document this simple feature. */ -export function htmlRoutesLoader() { +export function htmlRoutesLoader(): Plugin[] { return [ { name: 'gracile-html-route-loader', @@ -25,6 +25,6 @@ export default defineRoute({ }); `; }, - } satisfies Plugin, + }, ]; } diff --git a/packages/engine/src/vite/virtual-routes.ts b/packages/engine/src/vite/virtual-routes.ts index 2c7c35d..b982571 100644 --- a/packages/engine/src/vite/virtual-routes.ts +++ b/packages/engine/src/vite/virtual-routes.ts @@ -16,7 +16,7 @@ export function virtualRoutes({ // root: string; routes: RoutesManifest; renderedRoutes: RenderedRouteDefinition[]; -}) { +}): Plugin[] { const virtualModuleId = 'gracile:routes'; const resolvedVirtualModuleId = `\0${virtualModuleId}`; @@ -102,7 +102,7 @@ export function virtualRoutesClient({ routes: RoutesManifest; mode: 'static' | 'server'; gracileConfig: GracileConfig; -}) { +}): Plugin[] { const virtualModuleId = 'gracile:client:routes'; const resolvedVirtualModuleId = `\0${virtualModuleId}`;