UNPKG

rsbuild-plugin-react-router

Version:
70 lines (69 loc) 3.15 kB
import type { Route, PluginOptions, RouteManifestItem } from './types.js'; import { type RouteChunkCache } from './route-chunks.js'; /** * Structural equivalent of `RouteConfigEntry` from `@react-router/dev/routes`, * inlined so the public declaration files do not reference a devDependency * (which would fail to resolve for consumers with `skipLibCheck: false`). */ export interface RouteConfigEntry { id?: string; path?: string; index?: boolean; caseSensitive?: boolean; file: string; children?: RouteConfigEntry[]; } export declare function configRoutesToRouteManifest(appDirectory: string, routes: RouteConfigEntry[], rootId?: string): Record<string, Route>; export declare function configRoutesToRouteManifestEntries(appDirectory: string, routes: RouteConfigEntry[], rootId?: string): Array<[string, Route]>; type RouteChunkManifestOptions = { splitRouteModules?: boolean | 'enforce'; rootRouteFile?: string; isBuild?: boolean; cache?: RouteChunkCache; }; export type ReactRouterManifestForDev = { version: string; url: string; hmr?: { runtime: string; }; entry: { module: string; imports: string[]; css: string[]; }; sri?: Record<string, string> | true; routes: Record<string, RouteManifestItem>; }; export type ReactRouterManifestStats = { assetsByChunkName?: Record<string, string[]>; entrypointFilesByName?: Record<string, string[]>; }; type ReactRouterManifestStatsChunk = { files?: Iterable<string>; }; type ReactRouterManifestStatsEntrypoint = { getFiles?: () => Iterable<string>; }; type ReactRouterManifestStatsLookup<T> = Iterable<[string, T]> & { get?: (name: string) => T | undefined; }; type ReactRouterManifestStatsCompilation = { namedChunks: ReactRouterManifestStatsLookup<ReactRouterManifestStatsChunk>; entrypoints?: ReactRouterManifestStatsLookup<ReactRouterManifestStatsEntrypoint>; }; export declare const createReactRouterManifestStats: (compilation: ReactRouterManifestStatsCompilation | undefined, chunkNames?: ReadonlySet<string>) => ReactRouterManifestStats | undefined; export type RouteManifestModuleExports = Record<string, readonly string[]>; export type ReactRouterManifestGenerationResult = { manifest: ReactRouterManifestForDev; moduleExportsByRouteId: RouteManifestModuleExports; }; export declare const getReactRouterManifestPath: ({ version, isBuild, entryModulePath, }: { version: string; isBuild: boolean; entryModulePath?: string; }) => string; export declare const getReactRouterManifestChunkNames: (routes: Record<string, Route>, splitRouteModules?: boolean | "enforce") => Set<string>; export declare function generateReactRouterManifestForDev(routes: Record<string, Route>, options: PluginOptions, clientStats: ReactRouterManifestStats | undefined, context: string, assetPrefix?: string, routeChunkOptions?: RouteChunkManifestOptions): Promise<ReactRouterManifestGenerationResult>; export declare function getReactRouterManifestForDev(...args: Parameters<typeof generateReactRouterManifestForDev>): Promise<ReactRouterManifestForDev>; export {};