vite-plugin-react-server
Version:
Vite plugin for React Server Components (RSC)
24 lines • 1.16 kB
TypeScript
import type { LoaderContext } from "../types.js";
import type { RawSourceMap } from "source-map";
import type { LoadFnOutput, LoadHookContext } from "node:module";
export type LoaderResult = {
source: string;
map: RawSourceMap | null;
};
export type Loader = {
(id: string, context?: LoaderContext, nextLoad?: (id: string) => Promise<LoaderResult>): LoaderResult;
};
/**
* Creates a loader function that transforms modules and handles source maps.
* This function can be used in two ways:
*
* 1. As a direct transformer:
* - Takes source code and returns transformed code with source map attached
* - Used by transformModuleIfNeeded
*
* 2. As a loader factory:
* - Returns a loader function that takes a module ID and returns a LoaderResult
* - Used by the plugin to create loaders for different environments
*/
export declare function createDefaultLoader(defaultSource: string, defaultId?: string): (url: string, context?: Partial<LoadHookContext>, nextLoad?: (url: string, context?: Partial<LoadHookContext>) => LoadFnOutput | Promise<LoadFnOutput>) => Promise<LoadFnOutput>;
//# sourceMappingURL=createDefaultLoader.d.ts.map