Home / Function/ tryRewrite() — astro Function Reference

tryRewrite() — astro Function Reference

Architecture documentation for the tryRewrite() function in pipeline.ts from the astro codebase.

Entity Profile

Dependency Diagram

graph TD
  93232022_cf8d_03d9_d054_c2e6cc9ca329["tryRewrite()"]
  91572b20_ae8c_d5b0_82aa_5914d1622215["RunnablePipeline"]
  93232022_cf8d_03d9_d054_c2e6cc9ca329 -->|defined in| 91572b20_ae8c_d5b0_82aa_5914d1622215
  ddcb40c7_1fe7_8127_0dcf_33d7e687f835["getComponentByRoute()"]
  93232022_cf8d_03d9_d054_c2e6cc9ca329 -->|calls| ddcb40c7_1fe7_8127_0dcf_33d7e687f835
  style 93232022_cf8d_03d9_d054_c2e6cc9ca329 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/astro/src/vite-plugin-app/pipeline.ts lines 207–223

	async tryRewrite(payload: RewritePayload, request: Request): Promise<TryRewriteResult> {
		if (!this.routesList) {
			throw new Error('Missing manifest data. This is an internal error, please file an issue.');
		}
		const { routeData, pathname, newUrl } = findRouteToRewrite({
			payload,
			request,
			routes: this.routesList?.routes,
			trailingSlash: this.manifest.trailingSlash,
			buildFormat: this.manifest.buildFormat,
			base: this.manifest.base,
			outDir: this.manifest.outDir,
		});

		const componentInstance = await this.getComponentByRoute(routeData);
		return { newUrl, pathname, componentInstance, routeData };
	}

Domain

Subdomains

Frequently Asked Questions

What does tryRewrite() do?
tryRewrite() is a function in the astro codebase, defined in packages/astro/src/vite-plugin-app/pipeline.ts.
Where is tryRewrite() defined?
tryRewrite() is defined in packages/astro/src/vite-plugin-app/pipeline.ts at line 207.
What does tryRewrite() call?
tryRewrite() calls 1 function(s): getComponentByRoute.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free