Home / Function/ handleSvgDeduplication() — astro Function Reference

handleSvgDeduplication() — astro Function Reference

Architecture documentation for the handleSvgDeduplication() function in node.ts from the astro codebase.

Entity Profile

Dependency Diagram

graph TD
  609d5d31_892d_f263_3e18_9f1fa7712cd0["handleSvgDeduplication()"]
  cb45fbc5_a108_7969_b027_ddb8eab65943["node.ts"]
  609d5d31_892d_f263_3e18_9f1fa7712cd0 -->|defined in| cb45fbc5_a108_7969_b027_ddb8eab65943
  3a4327f8_602e_101e_f3dd_6616f760fe79["emitImageMetadata()"]
  3a4327f8_602e_101e_f3dd_6616f760fe79 -->|calls| 609d5d31_892d_f263_3e18_9f1fa7712cd0
  fbbb585c_fdc0_b9cd_1fbf_07460f90c0bc["keyFor()"]
  609d5d31_892d_f263_3e18_9f1fa7712cd0 -->|calls| fbbb585c_fdc0_b9cd_1fbf_07460f90c0bc
  style 609d5d31_892d_f263_3e18_9f1fa7712cd0 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/astro/src/assets/utils/node.ts lines 35–63

async function handleSvgDeduplication(
	fileData: Buffer,
	filename: string,
	fileEmitter: FileEmitter,
): Promise<string> {
	const contentHash = await generateContentHash(fileData.buffer as ArrayBuffer);
	const key = keyFor(contentHash);
	const existing = svgContentCache.get(key);

	if (existing) {
		// Emit file again with the same filename to get a new handle
		// This ensures Rollup knows about this handle while maintaining deduplication on disk
		const handle = fileEmitter({
			name: existing.filename,
			source: fileData,
			type: 'asset',
		});
		return handle;
	} else {
		// First time seeing this SVG content - emit it
		const handle = fileEmitter({
			name: filename,
			source: fileData,
			type: 'asset',
		});
		svgContentCache.set(key, { handle, filename });
		return handle;
	}
}

Domain

Subdomains

Calls

Frequently Asked Questions

What does handleSvgDeduplication() do?
handleSvgDeduplication() is a function in the astro codebase, defined in packages/astro/src/assets/utils/node.ts.
Where is handleSvgDeduplication() defined?
handleSvgDeduplication() is defined in packages/astro/src/assets/utils/node.ts at line 35.
What does handleSvgDeduplication() call?
handleSvgDeduplication() calls 1 function(s): keyFor.
What calls handleSvgDeduplication()?
handleSvgDeduplication() is called by 1 function(s): emitImageMetadata.

Analyze Your Own Codebase

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

Try Supermodel Free