Home / Function/ Identifier() — svelte Function Reference

Identifier() — svelte Function Reference

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

Entity Profile

Dependency Diagram

graph TD
  8424870e_58c8_6435_7e64_6b697e66ccb8["Identifier()"]
  ca0f0f27_a1ac_e3ec_cf1e_8b4bde24834b["Identifier.js"]
  8424870e_58c8_6435_7e64_6b697e66ccb8 -->|defined in| ca0f0f27_a1ac_e3ec_cf1e_8b4bde24834b
  27fded45_bc11_247b_d3fe_94831379f9ed["build_getter()"]
  8424870e_58c8_6435_7e64_6b697e66ccb8 -->|calls| 27fded45_bc11_247b_d3fe_94831379f9ed
  style 8424870e_58c8_6435_7e64_6b697e66ccb8 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/svelte/src/compiler/phases/3-transform/client/visitors/Identifier.js lines 11–45

export function Identifier(node, context) {
	const parent = /** @type {Node} */ (context.path.at(-1));

	if (is_reference(node, parent)) {
		if (node.name === '$$props') {
			return b.id('$$sanitized_props');
		}

		// Optimize prop access: If it's a member read access, we can use the $$props object directly
		const binding = context.state.scope.get(node.name);
		if (
			context.state.analysis.runes && // can't do this in legacy mode because the proxy does more than just read/write
			binding !== null &&
			node !== binding.node &&
			binding.kind === 'rest_prop'
		) {
			const grand_parent = context.path.at(-2);

			if (
				parent?.type === 'MemberExpression' &&
				!parent.computed &&
				grand_parent?.type !== 'AssignmentExpression' &&
				grand_parent?.type !== 'UpdateExpression'
			) {
				const key = /** @type {Identifier} */ (parent.property);

				if (!binding.metadata?.exclude_props?.includes(key.name)) {
					return b.id('$$props');
				}
			}
		}

		return build_getter(node, context.state);
	}
}

Domain

Subdomains

Frequently Asked Questions

What does Identifier() do?
Identifier() is a function in the svelte codebase, defined in packages/svelte/src/compiler/phases/3-transform/client/visitors/Identifier.js.
Where is Identifier() defined?
Identifier() is defined in packages/svelte/src/compiler/phases/3-transform/client/visitors/Identifier.js at line 11.
What does Identifier() call?
Identifier() calls 1 function(s): build_getter.

Analyze Your Own Codebase

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

Try Supermodel Free