Home / Function/ resolveClientDir() — astro Function Reference

resolveClientDir() — astro Function Reference

Architecture documentation for the resolveClientDir() function in serve-static.ts from the astro codebase.

Entity Profile

Dependency Diagram

graph TD
  6b657031_c1e0_9ceb_d4e4_6e9871dbb5c2["resolveClientDir()"]
  6f42a928_6dfc_6650_ab39_c8d254e11681["serve-static.ts"]
  6b657031_c1e0_9ceb_d4e4_6e9871dbb5c2 -->|defined in| 6f42a928_6dfc_6650_ab39_c8d254e11681
  5a2fbd03_4fb8_514e_1e0c_f298abe078e5["createStaticHandler()"]
  5a2fbd03_4fb8_514e_1e0c_f298abe078e5 -->|calls| 6b657031_c1e0_9ceb_d4e4_6e9871dbb5c2
  954586a3_864e_99af_8529_1fa34a515811["appendForwardSlash()"]
  6b657031_c1e0_9ceb_d4e4_6e9871dbb5c2 -->|calls| 954586a3_864e_99af_8529_1fa34a515811
  style 6b657031_c1e0_9ceb_d4e4_6e9871dbb5c2 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/integrations/node/src/serve-static.ts lines 125–140

function resolveClientDir(options: Options) {
	const clientURLRaw = new URL(options.client);
	const serverURLRaw = new URL(options.server);
	const rel = path.relative(url.fileURLToPath(serverURLRaw), url.fileURLToPath(clientURLRaw));

	// walk up the parent folders until you find the one that is the root of the server entry folder. This is how we find the client folder relatively.
	const serverFolder = path.basename(options.server);
	let serverEntryFolderURL = path.dirname(import.meta.url);
	while (!serverEntryFolderURL.endsWith(serverFolder)) {
		serverEntryFolderURL = path.dirname(serverEntryFolderURL);
	}
	const serverEntryURL = serverEntryFolderURL + '/entry.mjs';
	const clientURL = new URL(appendForwardSlash(rel), serverEntryURL);
	const client = url.fileURLToPath(clientURL);
	return client;
}

Domain

Subdomains

Frequently Asked Questions

What does resolveClientDir() do?
resolveClientDir() is a function in the astro codebase, defined in packages/integrations/node/src/serve-static.ts.
Where is resolveClientDir() defined?
resolveClientDir() is defined in packages/integrations/node/src/serve-static.ts at line 125.
What does resolveClientDir() call?
resolveClientDir() calls 1 function(s): appendForwardSlash.
What calls resolveClientDir()?
resolveClientDir() is called by 1 function(s): createStaticHandler.

Analyze Your Own Codebase

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

Try Supermodel Free