getModuleForRoute() — astro Function Reference
Architecture documentation for the getModuleForRoute() function in pipeline.ts from the astro codebase.
Entity Profile
Dependency Diagram
graph TD d47724cb_d240_2604_40ed_cb44bb423eb6["getModuleForRoute()"] 40ba2769_779c_63d9_4084_f451c2f62cd9["AppPipeline"] d47724cb_d240_2604_40ed_cb44bb423eb6 -->|defined in| 40ba2769_779c_63d9_4084_f451c2f62cd9 d52ff83d_4730_519f_5ab3_9c2089ed4d5d["getComponentByRoute()"] d52ff83d_4730_519f_5ab3_9c2089ed4d5d -->|calls| d47724cb_d240_2604_40ed_cb44bb423eb6 style d47724cb_d240_2604_40ed_cb44bb423eb6 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
packages/astro/src/core/app/pipeline.ts lines 85–121
async getModuleForRoute(route: RouteData): Promise<SinglePageBuiltModule> {
for (const defaultRoute of this.defaultRoutes) {
if (route.component === defaultRoute.component) {
return {
page: () => Promise.resolve(defaultRoute.instance),
};
}
}
let routeToProcess = route;
if (routeIsRedirect(route)) {
if (route.redirectRoute) {
// This is a static redirect
routeToProcess = route.redirectRoute;
} else {
// This is an external redirect, so we return a component stub
return RedirectSinglePageBuiltModule;
}
} else if (routeIsFallback(route)) {
// This is a i18n fallback route
routeToProcess = getFallbackRoute(route, this.manifest.routes);
}
if (this.manifest.pageMap) {
const importComponentInstance = this.manifest.pageMap.get(routeToProcess.component);
if (!importComponentInstance) {
throw new Error(
`Unexpectedly unable to find a component instance for route ${route.route}`,
);
}
return await importComponentInstance();
} else if (this.manifest.pageModule) {
return this.manifest.pageModule;
}
throw new Error(
"Astro couldn't find the correct page to render, probably because it wasn't correctly mapped for SSR usage. This is an internal error, please file an issue.",
);
}
Domain
Subdomains
Defined In
Called By
Source
Frequently Asked Questions
What does getModuleForRoute() do?
getModuleForRoute() is a function in the astro codebase, defined in packages/astro/src/core/app/pipeline.ts.
Where is getModuleForRoute() defined?
getModuleForRoute() is defined in packages/astro/src/core/app/pipeline.ts at line 85.
What calls getModuleForRoute()?
getModuleForRoute() is called by 1 function(s): getComponentByRoute.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free