vite-plugin-react-server
Version:
Vite plugin for React Server Components (RSC)
57 lines • 1.89 kB
TypeScript
import type { GenericModuleLoader, HtmlComponentType, RootComponentType } from "../types.js";
export type ComponentName = "Root" | "Html";
type ResolveComponentResult<T = unknown> = {
type: "success";
component: T;
error?: never;
} | {
type: "error";
error: Error;
component?: never;
} | {
type: "skip";
error?: never;
component?: never;
};
type ResolveComponentOptions = {
componentPath: string;
exportName: string;
loader: GenericModuleLoader;
};
/**
* Resolves a component (Root or Html) from a string path.
*
* This function handles:
* - String paths: "src/Root.tsx"
* - Fragment syntax: "src/components.tsx#MyRoot"
* - Export name resolution
*
* @param options.componentPath - The path to the component file
* @param options.exportName - The name of the export to resolve (e.g. 'Root', 'Html')
* @param options.loader - The loader function to use for loading the module
*
* @returns A result object containing the resolved component or error
*/
export declare function resolveComponent<T = RootComponentType | HtmlComponentType>(options: ResolveComponentOptions): Promise<ResolveComponentResult<T>>;
/**
* Resolves Root and Html components from user options.
*
* This function checks if Root/Html are strings and resolves them to components.
* If they're already components, it returns them as-is.
*
* @param options - Object containing Root, Html, and resolution options
* @returns Resolved components or original values if not strings
*/
export declare function resolveComponentOptions(options: {
Root: RootComponentType | string;
Html: HtmlComponentType | string;
rootExportName: string;
htmlExportName: string;
loader: GenericModuleLoader;
}): Promise<{
Root: RootComponentType;
Html: HtmlComponentType;
errors: Error[];
}>;
export {};
//# sourceMappingURL=resolveComponent.d.ts.map