dev.ts — astro Source File
Architecture documentation for dev.ts, a typescript file in the astro codebase. 10 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR 3f373c63_ced2_f6ce_9a33_2b040b86d1b3["dev.ts"] e9b74c5a_8d34_34a7_e196_5e41b87214aa["../types/astro.js"] 3f373c63_ced2_f6ce_9a33_2b040b86d1b3 --> e9b74c5a_8d34_34a7_e196_5e41b87214aa a4f2698c_5256_262a_ba7c_f72b51878d10["../core/app/types.js"] 3f373c63_ced2_f6ce_9a33_2b040b86d1b3 --> a4f2698c_5256_262a_ba7c_f72b51878d10 a3d56727_13c4_68fd_1bf6_c0b09d68466f["../core/routing/match.js"] 3f373c63_ced2_f6ce_9a33_2b040b86d1b3 --> a3d56727_13c4_68fd_1bf6_c0b09d68466f 7a4adbcc_2764_196a_ff68_0aefb2d8bc56["../../prerender/routing.js"] 3f373c63_ced2_f6ce_9a33_2b040b86d1b3 --> 7a4adbcc_2764_196a_ff68_0aefb2d8bc56 feb254e4_908a_ebac_cf06_c741bffea12a["../core/render/index.js"] 3f373c63_ced2_f6ce_9a33_2b040b86d1b3 --> feb254e4_908a_ebac_cf06_c741bffea12a b3e8a9be_d20e_da21_abaa_3cb61c3f5a15["../core/routing/helpers.js"] 3f373c63_ced2_f6ce_9a33_2b040b86d1b3 --> b3e8a9be_d20e_da21_abaa_3cb61c3f5a15 8df634da_0f30_1e1f_1314_2439b0c9baab["../core/errors/errors-data.js"] 3f373c63_ced2_f6ce_9a33_2b040b86d1b3 --> 8df634da_0f30_1e1f_1314_2439b0c9baab dd6187d6_53c4_ce90_a1d1_3a0b5e7e7d3f["../../core/errors/errors.js"] 3f373c63_ced2_f6ce_9a33_2b040b86d1b3 --> dd6187d6_53c4_ce90_a1d1_3a0b5e7e7d3f baa53824_73a3_1e03_2043_4d0c058ecca5["../types/public/index.js"] 3f373c63_ced2_f6ce_9a33_2b040b86d1b3 --> baa53824_73a3_1e03_2043_4d0c058ecca5 0a7232f9_1027_cf2d_cc88_6e09a54bf913["./pipeline.js"] 3f373c63_ced2_f6ce_9a33_2b040b86d1b3 --> 0a7232f9_1027_cf2d_cc88_6e09a54bf913 style 3f373c63_ced2_f6ce_9a33_2b040b86d1b3 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
/**
* Use this module only to have functions needed in development
*/
import type { RoutesList } from '../../types/astro.js';
import type { SSRManifest } from '../app/types.js';
import { matchAllRoutes } from './match.js';
import { getSortedPreloadedMatches } from '../../prerender/routing.js';
import { getProps } from '../render/index.js';
import { getCustom404Route } from './helpers.js';
import { NoMatchingStaticPathFound } from '../errors/errors-data.js';
import { isAstroError } from '../errors/errors.js';
import type { RouteData } from '../../types/public/index.js';
import type { RunnablePipeline } from '../../vite-plugin-app/pipeline.js';
interface MatchedRoute {
route: RouteData;
filePath: URL;
resolvedPathname: string;
}
export async function matchRoute(
pathname: string,
routesList: RoutesList,
pipeline: RunnablePipeline,
manifest: SSRManifest,
): Promise<MatchedRoute | undefined> {
const { logger, routeCache } = pipeline;
const matches = matchAllRoutes(pathname, routesList);
const preloadedMatches = getSortedPreloadedMatches({
pipeline,
matches,
manifest,
});
for await (const { route: maybeRoute, filePath } of preloadedMatches) {
// attempt to get static paths
// if this fails, we have a bad URL match!
try {
await getProps({
mod: await pipeline.getComponentByRoute(maybeRoute),
routeData: maybeRoute,
routeCache,
pathname: pathname,
logger,
serverLike: pipeline.manifest.serverLike,
base: manifest.base,
trailingSlash: manifest.trailingSlash,
});
return {
route: maybeRoute,
filePath,
resolvedPathname: pathname,
};
} catch (e) {
// Ignore error for no matching static paths
if (isAstroError(e) && e.title === NoMatchingStaticPathFound.title) {
continue;
}
throw e;
}
}
// Try without `.html` extensions or `index.html` in request URLs to mimic
// routing behavior in production builds. This supports both file and directory
// build formats, and is necessary based on how the manifest tracks build targets.
const altPathname = pathname.replace(/\/index\.html$/, '/').replace(/\.html$/, '');
if (altPathname !== pathname) {
return await matchRoute(altPathname, routesList, pipeline, manifest);
}
if (matches.length) {
const possibleRoutes = matches.flatMap((route) => route.component);
logger.warn(
'router',
`${NoMatchingStaticPathFound.message(
pathname,
)}\n\n${NoMatchingStaticPathFound.hint(possibleRoutes)}`,
);
}
const custom404 = getCustom404Route(routesList);
if (custom404) {
const filePath = new URL(`./${custom404.component}`, manifest.rootDir);
return {
route: custom404,
filePath,
resolvedPathname: pathname,
};
}
return undefined;
}
Domain
Subdomains
Functions
Types
Dependencies
- ../../core/errors/errors.js
- ../../prerender/routing.js
- ../core/app/types.js
- ../core/errors/errors-data.js
- ../core/render/index.js
- ../core/routing/helpers.js
- ../core/routing/match.js
- ../types/astro.js
- ../types/public/index.js
- ./pipeline.js
Source
Frequently Asked Questions
What does dev.ts do?
dev.ts is a source file in the astro codebase, written in typescript. It belongs to the CoreAstro domain, CoreMiddleware subdomain.
What functions are defined in dev.ts?
dev.ts defines 1 function(s): matchRoute.
What does dev.ts depend on?
dev.ts imports 10 module(s): ../../core/errors/errors.js, ../../prerender/routing.js, ../core/app/types.js, ../core/errors/errors-data.js, ../core/render/index.js, ../core/routing/helpers.js, ../core/routing/match.js, ../types/astro.js, and 2 more.
Where is dev.ts in the architecture?
dev.ts is located at packages/astro/src/core/routing/dev.ts (domain: CoreAstro, subdomain: CoreMiddleware, directory: packages/astro/src/core/routing).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free