Home / Function/ transform() — astro Function Reference

transform() — astro Function Reference

Architecture documentation for the transform() function in index.ts from the astro codebase.

Entity Profile

Dependency Diagram

graph TD
  cbe7320c_f3a1_8d77_345c_0408cb7fa97e["transform()"]
  0672f845_9adf_2937_66ed_1ac9db7b7fdd["index.ts"]
  cbe7320c_f3a1_8d77_345c_0408cb7fa97e -->|defined in| 0672f845_9adf_2937_66ed_1ac9db7b7fdd
  style cbe7320c_f3a1_8d77_345c_0408cb7fa97e fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/astro/src/vite-plugin-html/transform/index.ts lines 7–20

export async function transform(code: string, id: string) {
	const s = new MagicString(code, { filename: id });
	const parser = rehype().data('settings', { fragment: true }).use(escape, { s }).use(slots, { s });

	const vfile = new VFile({ value: code, path: id });
	await parser.process(vfile);
	s.prepend(`function render({ slots: ${SLOT_PREFIX} }) {\n\t\treturn \``);
	s.append('`\n\t}\nrender["astro:html"] = true;\nexport default render;');

	return {
		code: s.toString(),
		map: s.generateMap({ hires: 'boundary' }),
	};
}

Domain

Subdomains

Frequently Asked Questions

What does transform() do?
transform() is a function in the astro codebase, defined in packages/astro/src/vite-plugin-html/transform/index.ts.
Where is transform() defined?
transform() is defined in packages/astro/src/vite-plugin-html/transform/index.ts at line 7.

Analyze Your Own Codebase

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

Try Supermodel Free