vite-plugin-react-server
Version:
Vite plugin for React Server Components (RSC)
42 lines • 1.96 kB
TypeScript
import type { PageName, PropsName, ResolvedUserOptions } from "../types.js";
import type { AutoDiscoveredFiles } from "../types.js";
type GetRouteFilesSuccess = {
type: "success";
page: string;
props?: string | undefined;
root?: string | undefined;
html?: string | undefined;
};
type GetRouteFilesError = {
type: "error";
error: unknown;
};
/**
* Gets page and props file paths for a route using cached discovery + dynamic fallback.
*
* ## RUNTIME RESOLUTION STRATEGY
* This function implements a two-tier lookup strategy:
*
* 1. **FAST PATH**: Check auto-discovered urlMap cache first
* - Built by resolveBuildPages.ts from build.pages array
* - O(1) lookup, no I/O, very fast
* - Used for routes that were pre-discovered at build time
*
* 2. **FALLBACK PATH**: Dynamic resolution via resolveUrlOption
* - Only when route not found in urlMap cache
* - Calls Page/props resolver functions with the route URL
* - Enables dynamic routing beyond what's in build.pages
* - Slower due to function calls + potential I/O
*
* ## Auto-Discovery Integration:
* Results from dynamic resolution are cached back into autoDiscoveredFiles.urlMap
* for future requests, so each route is only resolved dynamically once.
*
* ## Function Resolver Support:
* This is where router functions like `(url) => "./src/pages/" + url + ".tsx"`
* are actually called. The dynamic nature allows runtime route resolution but
* creates complexity for static analysis and build-time discovery.
*/
export declare const getRouteFiles: (route: string, autoDiscoveredFiles: AutoDiscoveredFiles, userOptions: Pick<ResolvedUserOptions, PageName | PropsName | "Root" | "Html" | "moduleBasePath" | "verbose" | "pageExportName" | "propsExportName" | "rootExportName" | "htmlExportName">, logger?: import("vite").Logger) => Promise<GetRouteFilesSuccess | GetRouteFilesError>;
export {};
//# sourceMappingURL=getRouteFiles.d.ts.map