Skip to content

Commit

Permalink
fix: vite 6 typings somehow requires to return explicit plugin type f…
Browse files Browse the repository at this point in the history
…or factories
  • Loading branch information
JulianCataldo committed Dec 21, 2024
1 parent a4e9093 commit b264075
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 8 deletions.
16 changes: 12 additions & 4 deletions packages/engine/src/vite/build-routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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,
Expand Down Expand Up @@ -103,7 +111,7 @@ export const buildRoutes = async ({

return null;
},
} satisfies Plugin,
},

{
name: 'gracile-collect-handler-assets',
Expand Down Expand Up @@ -180,7 +188,7 @@ export const buildRoutes = async ({
}
}
},
} satisfies Plugin,
},
],
};
};
4 changes: 2 additions & 2 deletions packages/engine/src/vite/html-routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -25,6 +25,6 @@ export default defineRoute({
});
`;
},
} satisfies Plugin,
},
];
}
4 changes: 2 additions & 2 deletions packages/engine/src/vite/virtual-routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export function virtualRoutes({
// root: string;
routes: RoutesManifest;
renderedRoutes: RenderedRouteDefinition[];
}) {
}): Plugin[] {
const virtualModuleId = 'gracile:routes';
const resolvedVirtualModuleId = `\0${virtualModuleId}`;

Expand Down Expand Up @@ -102,7 +102,7 @@ export function virtualRoutesClient({
routes: RoutesManifest;
mode: 'static' | 'server';
gracileConfig: GracileConfig;
}) {
}): Plugin[] {
const virtualModuleId = 'gracile:client:routes';
const resolvedVirtualModuleId = `\0${virtualModuleId}`;

Expand Down

0 comments on commit b264075

Please sign in to comment.