MCPcopy Create free account
hub / github.com/remix-run/react-router / getRouteMetadata

Function getRouteMetadata

packages/react-router-dev/vite/plugin.ts:2845–2912  ·  view source on GitHub ↗
(
  cache: Cache,
  ctx: ReactRouterPluginContext,
  viteChildCompiler: Vite.ViteDevServer | null,
  route: RouteManifestEntry,
  readRouteFile?: () => string | Promise<string>,
)

Source from the content-addressed store, hash-verified

2843}
2844
2845async function getRouteMetadata(
2846 cache: Cache,
2847 ctx: ReactRouterPluginContext,
2848 viteChildCompiler: Vite.ViteDevServer | null,
2849 route: RouteManifestEntry,
2850 readRouteFile?: () => string | Promise<string>,
2851): Promise<ManifestRoute & { url: string }> {
2852 let routeFile = route.file;
2853 let sourceExports = await getRouteModuleExports(
2854 viteChildCompiler,
2855 ctx,
2856 route.file,
2857 readRouteFile,
2858 );
2859
2860 let { hasRouteChunkByExportName } = await detectRouteChunksIfEnabled(
2861 cache,
2862 ctx,
2863 routeFile,
2864 { routeFile, readRouteFile, viteChildCompiler },
2865 );
2866
2867 let moduleUrl = combineURLs(
2868 ctx.publicPath,
2869 `${resolveFileUrl(
2870 ctx,
2871 resolveRelativeRouteFilePath(route, ctx.reactRouterConfig),
2872 )}`,
2873 );
2874
2875 let info: ManifestRoute & { url: string } = {
2876 id: route.id,
2877 parentId: route.parentId,
2878 path: route.path,
2879 index: route.index,
2880 caseSensitive: route.caseSensitive,
2881 url: combineURLs(
2882 ctx.publicPath,
2883 "/" +
2884 path.relative(
2885 ctx.rootDirectory,
2886 resolveRelativeRouteFilePath(route, ctx.reactRouterConfig),
2887 ),
2888 ),
2889 module: `${moduleUrl}?import`, // Ensure the Vite dev server responds with a JS module
2890 clientActionModule: hasRouteChunkByExportName.clientAction
2891 ? `${getRouteChunkModuleId(moduleUrl, "clientAction")}`
2892 : undefined,
2893 clientLoaderModule: hasRouteChunkByExportName.clientLoader
2894 ? `${getRouteChunkModuleId(moduleUrl, "clientLoader")}`
2895 : undefined,
2896 clientMiddlewareModule: hasRouteChunkByExportName.clientMiddleware
2897 ? `${getRouteChunkModuleId(moduleUrl, "clientMiddleware")}`
2898 : undefined,
2899 hydrateFallbackModule: hasRouteChunkByExportName.HydrateFallback
2900 ? `${getRouteChunkModuleId(moduleUrl, "HydrateFallback")}`
2901 : undefined,
2902 hasAction: sourceExports.includes("action"),

Callers 1

handleHotUpdateFunction · 0.85

Calls 6

combineURLsFunction · 0.90
resolveFileUrlFunction · 0.90
getRouteChunkModuleIdFunction · 0.90
getRouteModuleExportsFunction · 0.85

Tested by

no test coverage detected