Home / File/ Identifier.js — svelte Source File

Identifier.js — svelte Source File

Architecture documentation for Identifier.js, a javascript file in the svelte codebase. 15 imports, 1 dependents.

File javascript Compiler Transformer 15 imports 1 dependents 1 functions

Entity Profile

Dependency Diagram

graph LR
  dbcd64ee_7333_aa92_9b8e_ed189c6c4449["Identifier.js"]
  c518b20b_2355_7b11_4ac2_2d9bb5dcfb43["utils.js"]
  dbcd64ee_7333_aa92_9b8e_ed189c6c4449 --> c518b20b_2355_7b11_4ac2_2d9bb5dcfb43
  88db3726_5740_3eb8_99fb_4b297fb19b24["should_proxy"]
  dbcd64ee_7333_aa92_9b8e_ed189c6c4449 --> 88db3726_5740_3eb8_99fb_4b297fb19b24
  495501a4_a342_6a4d_ac11_e3e2fee8b218["errors.js"]
  dbcd64ee_7333_aa92_9b8e_ed189c6c4449 --> 495501a4_a342_6a4d_ac11_e3e2fee8b218
  a146f6ac_0088_8736_b6ce_318f9f115170["e"]
  dbcd64ee_7333_aa92_9b8e_ed189c6c4449 --> a146f6ac_0088_8736_b6ce_318f9f115170
  56a689f9_11c0_cc76_bd60_41bb6dc96475["warnings.js"]
  dbcd64ee_7333_aa92_9b8e_ed189c6c4449 --> 56a689f9_11c0_cc76_bd60_41bb6dc96475
  3246e0bc_b9fc_f638_5e35_41e8c39a2408["w"]
  dbcd64ee_7333_aa92_9b8e_ed189c6c4449 --> 3246e0bc_b9fc_f638_5e35_41e8c39a2408
  2aa63f4e_82c9_33e3_ac6c_5f3d46250522["utils.js"]
  dbcd64ee_7333_aa92_9b8e_ed189c6c4449 --> 2aa63f4e_82c9_33e3_ac6c_5f3d46250522
  96840921_f43d_a26b_1d2e_cd28c0fd6d73["is_rune"]
  dbcd64ee_7333_aa92_9b8e_ed189c6c4449 --> 96840921_f43d_a26b_1d2e_cd28c0fd6d73
  c4b4ac8d_9914_5ede_1aea_723bf80d2e9b["fragment.js"]
  dbcd64ee_7333_aa92_9b8e_ed189c6c4449 --> c4b4ac8d_9914_5ede_1aea_723bf80d2e9b
  313d2a82_30ea_3161_3aad_0cc2094979aa["mark_subtree_dynamic"]
  dbcd64ee_7333_aa92_9b8e_ed189c6c4449 --> 313d2a82_30ea_3161_3aad_0cc2094979aa
  ee93d8a6_6fde_b1c1_e15b_3a4da5326305["scope.js"]
  dbcd64ee_7333_aa92_9b8e_ed189c6c4449 --> ee93d8a6_6fde_b1c1_e15b_3a4da5326305
  bed91719_d047_2256_e199_ee875d5f49b9["get_rune"]
  dbcd64ee_7333_aa92_9b8e_ed189c6c4449 --> bed91719_d047_2256_e199_ee875d5f49b9
  bbca3d2a_42c8_b215_d3b5_5077ccaf0797["nodes.js"]
  dbcd64ee_7333_aa92_9b8e_ed189c6c4449 --> bbca3d2a_42c8_b215_d3b5_5077ccaf0797
  fa6a31b3_d3a3_4556_d879_573977db1aca["is_component_node"]
  dbcd64ee_7333_aa92_9b8e_ed189c6c4449 --> fa6a31b3_d3a3_4556_d879_573977db1aca
  style dbcd64ee_7333_aa92_9b8e_ed189c6c4449 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

/** @import { Expression, Identifier } from 'estree' */
/** @import { Context } from '../types' */
import is_reference from 'is-reference';
import { should_proxy } from '../../3-transform/client/utils.js';
import * as e from '../../../errors.js';
import * as w from '../../../warnings.js';
import { is_rune } from '../../../../utils.js';
import { mark_subtree_dynamic } from './shared/fragment.js';
import { get_rune } from '../../scope.js';
import { is_component_node } from '../../nodes.js';

/**
 * @param {Identifier} node
 * @param {Context} context
 */
export function Identifier(node, context) {
	let i = context.path.length;
	let parent = /** @type {Expression} */ (context.path[--i]);

	if (!is_reference(node, parent)) {
		return;
	}

	mark_subtree_dynamic(context.path);

	// If we are using arguments outside of a function, then throw an error
	if (
		node.name === 'arguments' &&
		!context.path.some((n) => n.type === 'FunctionDeclaration' || n.type === 'FunctionExpression')
	) {
		e.invalid_arguments_usage(node);
	}

	// `$$slots` exists even in runes mode
	if (node.name === '$$slots') {
		context.state.analysis.uses_slots = true;
	}

	if (context.state.analysis.runes) {
		if (
			is_rune(node.name) &&
			context.state.scope.get(node.name) === null &&
			context.state.scope.get(node.name.slice(1))?.kind !== 'store_sub'
		) {
			/** @type {Expression} */
			let current = node;
			let name = node.name;

			while (parent.type === 'MemberExpression') {
				if (parent.computed) e.rune_invalid_computed_property(parent);
				name += `.${/** @type {Identifier} */ (parent.property).name}`;

				current = parent;
				parent = /** @type {Expression} */ (context.path[--i]);

				if (!is_rune(name)) {
					if (name === '$effect.active') {
						e.rune_renamed(parent, '$effect.active', '$effect.tracking');
					}

// ... (134 more lines)

Domain

Subdomains

Functions

Frequently Asked Questions

What does Identifier.js do?
Identifier.js is a source file in the svelte codebase, written in javascript. It belongs to the Compiler domain, Transformer subdomain.
What functions are defined in Identifier.js?
Identifier.js defines 1 function(s): Identifier.
What does Identifier.js depend on?
Identifier.js imports 15 module(s): e, errors.js, fragment.js, get_rune, is-reference, is_component_node, is_rune, mark_subtree_dynamic, and 7 more.
What files import Identifier.js?
Identifier.js is imported by 1 file(s): index.js.
Where is Identifier.js in the architecture?
Identifier.js is located at packages/svelte/src/compiler/phases/2-analyze/visitors/Identifier.js (domain: Compiler, subdomain: Transformer, directory: packages/svelte/src/compiler/phases/2-analyze/visitors).

Analyze Your Own Codebase

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

Try Supermodel Free