Home / Function/ buildClientDirectiveEntrypoint() — astro Function Reference

buildClientDirectiveEntrypoint() — astro Function Reference

Architecture documentation for the buildClientDirectiveEntrypoint() function in build.ts from the astro codebase.

Entity Profile

Dependency Diagram

graph TD
  3ed3bd6d_1df1_3dc8_55c4_721da55cbf84["buildClientDirectiveEntrypoint()"]
  09de27d4_1fc5_e58b_fa6e_eee2e4636d42["build.ts"]
  3ed3bd6d_1df1_3dc8_55c4_721da55cbf84 -->|defined in| 09de27d4_1fc5_e58b_fa6e_eee2e4636d42
  style 3ed3bd6d_1df1_3dc8_55c4_721da55cbf84 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/astro/src/core/client-directive/build.ts lines 7–38

export async function buildClientDirectiveEntrypoint(
	name: string,
	entrypoint: string | URL,
	root: URL,
) {
	const stringifiedName = JSON.stringify(name);
	const stringifiedEntrypoint = JSON.stringify(entrypoint);

	// NOTE: when updating this stdin code, make sure to also update `packages/astro/scripts/prebuild.ts`
	// that prebuilds the client directive with a similar code too.
	const output = await build({
		stdin: {
			contents: `\
import directive from ${stringifiedEntrypoint};

(self.Astro || (self.Astro = {}))[${stringifiedName}] = directive;

window.dispatchEvent(new Event('astro:' + ${stringifiedName}));`,
			resolveDir: fileURLToPath(root),
		},
		absWorkingDir: fileURLToPath(root),
		format: 'iife',
		minify: true,
		bundle: true,
		write: false,
	});

	const outputFile = output.outputFiles?.[0];
	if (!outputFile) return '';

	return outputFile.text;
}

Domain

Subdomains

Frequently Asked Questions

What does buildClientDirectiveEntrypoint() do?
buildClientDirectiveEntrypoint() is a function in the astro codebase, defined in packages/astro/src/core/client-directive/build.ts.
Where is buildClientDirectiveEntrypoint() defined?
buildClientDirectiveEntrypoint() is defined in packages/astro/src/core/client-directive/build.ts at line 7.

Analyze Your Own Codebase

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

Try Supermodel Free