Home / Function/ transform_component() — svelte Function Reference

transform_component() — svelte Function Reference

Architecture documentation for the transform_component() function in index.js from the svelte codebase.

Function javascript Compiler Transformer calls 5 called by 1

Entity Profile

Dependency Diagram

graph TD
  0accce76_056a_b49e_69ca_069fe7e3e216["transform_component()"]
  f1cb032f_d7a0_6877_cebc_2e5f4505e958["index.js"]
  0accce76_056a_b49e_69ca_069fe7e3e216 -->|defined in| f1cb032f_d7a0_6877_cebc_2e5f4505e958
  10e19602_80ed_a1f9_ddcc_2ac1ab16e385["compile()"]
  10e19602_80ed_a1f9_ddcc_2ac1ab16e385 -->|calls| 0accce76_056a_b49e_69ca_069fe7e3e216
  b507285b_8f11_234a_936c_682b2ac1e15b["server_component()"]
  0accce76_056a_b49e_69ca_069fe7e3e216 -->|calls| b507285b_8f11_234a_936c_682b2ac1e15b
  662808dd_8096_e53e_2dc5_8a5903c50472["client_component()"]
  0accce76_056a_b49e_69ca_069fe7e3e216 -->|calls| 662808dd_8096_e53e_2dc5_8a5903c50472
  8164d272_5d30_264a_68d0_0339d7d146e1["get_source_name()"]
  0accce76_056a_b49e_69ca_069fe7e3e216 -->|calls| 8164d272_5d30_264a_68d0_0339d7d146e1
  cbb1ee69_356b_2015_1118_b75b5cb5088f["merge_with_preprocessor_map()"]
  0accce76_056a_b49e_69ca_069fe7e3e216 -->|calls| cbb1ee69_356b_2015_1118_b75b5cb5088f
  1129e6de_ad88_9249_cdc1_424cf9bba55e["render_stylesheet()"]
  0accce76_056a_b49e_69ca_069fe7e3e216 -->|calls| 1129e6de_ad88_9249_cdc1_424cf9bba55e
  style 0accce76_056a_b49e_69ca_069fe7e3e216 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/svelte/src/compiler/phases/3-transform/index.js lines 19–62

export function transform_component(analysis, source, options) {
	if (options.generate === false) {
		return {
			js: /** @type {any} */ (null),
			css: null,
			warnings: state.warnings, // set afterwards
			metadata: {
				runes: analysis.runes
			},
			ast: /** @type {any} */ (null) // set afterwards
		};
	}

	const program =
		options.generate === 'server'
			? server_component(analysis, options)
			: client_component(analysis, options);

	const js_source_name = get_source_name(options.filename, options.outputFilename, 'input.svelte');

	const js = print(/** @type {Node} */ (program), ts({ comments: analysis.comments }), {
		// include source content; makes it easier/more robust looking up the source map code
		// (else esrap does return null for source and sourceMapContent which may trip up tooling)
		sourceMapContent: source,
		sourceMapSource: js_source_name
	});

	merge_with_preprocessor_map(js, options, js_source_name);

	const css =
		analysis.css.ast && !analysis.inject_styles
			? render_stylesheet(source, analysis, options)
			: null;

	return {
		js,
		css,
		warnings: state.warnings, // set afterwards. TODO apply preprocessor sourcemap
		metadata: {
			runes: analysis.runes
		},
		ast: /** @type {any} */ (null) // set afterwards
	};
}

Domain

Subdomains

Called By

Frequently Asked Questions

What does transform_component() do?
transform_component() is a function in the svelte codebase, defined in packages/svelte/src/compiler/phases/3-transform/index.js.
Where is transform_component() defined?
transform_component() is defined in packages/svelte/src/compiler/phases/3-transform/index.js at line 19.
What does transform_component() call?
transform_component() calls 5 function(s): client_component, get_source_name, merge_with_preprocessor_map, render_stylesheet, server_component.
What calls transform_component()?
transform_component() is called by 1 function(s): compile.

Analyze Your Own Codebase

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

Try Supermodel Free