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
  3a71f207_88eb_a31f_8d09_b750c013e060["tryRewrite()"]
  1856d10d_49b6_d49e_0f37_cbee2beb3083["NonRunnablePipeline"]
  3a71f207_88eb_a31f_8d09_b750c013e060 -->|defined in| 1856d10d_49b6_d49e_0f37_cbee2beb3083
  e63fd70c_59a1_5108_dff0_9a497e524393["getComponentByRoute()"]
  3a71f207_88eb_a31f_8d09_b750c013e060 -->|calls| e63fd70c_59a1_5108_dff0_9a497e524393
  style 3a71f207_88eb_a31f_8d09_b750c013e060 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/astro/src/core/app/dev/pipeline.ts lines 140–153

	async tryRewrite(payload: RewritePayload, request: Request): Promise<TryRewriteResult> {
		const { newUrl, pathname, routeData } = findRouteToRewrite({
			payload,
			request,
			routes: this.manifest?.routes.map((r) => r.routeData),
			trailingSlash: this.manifest.trailingSlash,
			buildFormat: this.manifest.buildFormat,
			base: this.manifest.base,
			outDir: this.manifest?.serverLike ? this.manifest.buildClientDir : 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/core/app/dev/pipeline.ts.
Where is tryRewrite() defined?
tryRewrite() is defined in packages/astro/src/core/app/dev/pipeline.ts at line 140.
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