Home / Function/ resolveIdToUrl() — astro Function Reference

resolveIdToUrl() — astro Function Reference

Architecture documentation for the resolveIdToUrl() function in viteUtils.ts from the astro codebase.

Entity Profile

Dependency Diagram

graph TD
  0ac27604_21c9_4831_55be_be77e76e3f6d["resolveIdToUrl()"]
  b7a40933_4ff9_20ad_c87e_be8112bdd644["viteUtils.ts"]
  0ac27604_21c9_4831_55be_be77e76e3f6d -->|defined in| b7a40933_4ff9_20ad_c87e_be8112bdd644
  b7d7daa6_6e47_6026_9d0b_458be9f6257c["normalizePath()"]
  0ac27604_21c9_4831_55be_be77e76e3f6d -->|calls| b7d7daa6_6e47_6026_9d0b_458be9f6257c
  style 0ac27604_21c9_4831_55be_be77e76e3f6d fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/astro/src/core/viteUtils.ts lines 51–70

export async function resolveIdToUrl(loader: ModuleLoader, id: string, root?: URL) {
	let resultId = await loader.resolveId(id, undefined);
	// Try resolve jsx to tsx
	if (!resultId && id.endsWith('.jsx')) {
		resultId = await loader.resolveId(id.slice(0, -4), undefined);
	}
	if (!resultId) {
		return VALID_ID_PREFIX + id;
	}
	if (path.isAbsolute(resultId)) {
		const normalizedRoot = root && normalizePath(fileURLToPath(root));
		// Convert to root-relative path if path is inside root
		if (normalizedRoot && resultId.startsWith(normalizedRoot)) {
			return resultId.slice(normalizedRoot.length - 1);
		} else {
			return '/@fs' + prependForwardSlash(resultId);
		}
	}
	return VALID_ID_PREFIX + resultId;
}

Domain

Subdomains

Frequently Asked Questions

What does resolveIdToUrl() do?
resolveIdToUrl() is a function in the astro codebase, defined in packages/astro/src/core/viteUtils.ts.
Where is resolveIdToUrl() defined?
resolveIdToUrl() is defined in packages/astro/src/core/viteUtils.ts at line 51.
What does resolveIdToUrl() call?
resolveIdToUrl() calls 1 function(s): normalizePath.

Analyze Your Own Codebase

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

Try Supermodel Free