VariableDeclaration.js — svelte Source File
Architecture documentation for VariableDeclaration.js, a javascript file in the svelte codebase. 17 imports, 1 dependents.
Entity Profile
Dependency Diagram
graph LR 12047c60_7eb9_7476_83e2_7d8004a6f868["VariableDeclaration.js"] 62f818c8_e890_17ed_5ec1_92f953d4a7a6["state.js"] 12047c60_7eb9_7476_83e2_7d8004a6f868 --> 62f818c8_e890_17ed_5ec1_92f953d4a7a6 7a7783f8_ffa6_0cc3_61b0_031882649535["is_ignored"] 12047c60_7eb9_7476_83e2_7d8004a6f868 --> 7a7783f8_ffa6_0cc3_61b0_031882649535 bde97aff_493a_f552_a038_3e029fefca90["locate_node"] 12047c60_7eb9_7476_83e2_7d8004a6f868 --> bde97aff_493a_f552_a038_3e029fefca90 0c5c28a7_226d_4e7c_e75e_0853c0a9fc2c["ast.js"] 12047c60_7eb9_7476_83e2_7d8004a6f868 --> 0c5c28a7_226d_4e7c_e75e_0853c0a9fc2c c254e734_2224_c309_f1f8_bb064e80b1af["extract_paths"] 12047c60_7eb9_7476_83e2_7d8004a6f868 --> c254e734_2224_c309_f1f8_bb064e80b1af a5d434ec_3ca3_7fe0_cea3_58f60f017b7b["save"] 12047c60_7eb9_7476_83e2_7d8004a6f868 --> a5d434ec_3ca3_7fe0_cea3_58f60f017b7b d1e506f3_176e_9858_77c8_809e5b1d3b25["assert.js"] 12047c60_7eb9_7476_83e2_7d8004a6f868 --> d1e506f3_176e_9858_77c8_809e5b1d3b25 ee93d8a6_6fde_b1c1_e15b_3a4da5326305["scope.js"] 12047c60_7eb9_7476_83e2_7d8004a6f868 --> ee93d8a6_6fde_b1c1_e15b_3a4da5326305 bed91719_d047_2256_e199_ee875d5f49b9["get_rune"] 12047c60_7eb9_7476_83e2_7d8004a6f868 --> bed91719_d047_2256_e199_ee875d5f49b9 c518b20b_2355_7b11_4ac2_2d9bb5dcfb43["utils.js"] 12047c60_7eb9_7476_83e2_7d8004a6f868 --> c518b20b_2355_7b11_4ac2_2d9bb5dcfb43 5f0f3809_9fa1_84c1_24be_92d8863f2fb1["get_prop_source"] 12047c60_7eb9_7476_83e2_7d8004a6f868 --> 5f0f3809_9fa1_84c1_24be_92d8863f2fb1 5f828ae1_5f83_74a8_876a_ea54ea47b588["is_prop_source"] 12047c60_7eb9_7476_83e2_7d8004a6f868 --> 5f828ae1_5f83_74a8_876a_ea54ea47b588 03ec0ace_6e52_c362_5e4b_06e8333b938f["is_state_source"] 12047c60_7eb9_7476_83e2_7d8004a6f868 --> 03ec0ace_6e52_c362_5e4b_06e8333b938f 88db3726_5740_3eb8_99fb_4b297fb19b24["should_proxy"] 12047c60_7eb9_7476_83e2_7d8004a6f868 --> 88db3726_5740_3eb8_99fb_4b297fb19b24 style 12047c60_7eb9_7476_83e2_7d8004a6f868 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
/** @import { CallExpression, Expression, Identifier, Literal, VariableDeclaration, VariableDeclarator } from 'estree' */
/** @import { Binding } from '#compiler' */
/** @import { ComponentContext } from '../types' */
import { dev, is_ignored, locate_node } from '../../../../state.js';
import { extract_paths, save } from '../../../../utils/ast.js';
import * as b from '#compiler/builders';
import * as assert from '../../../../utils/assert.js';
import { get_rune } from '../../../scope.js';
import { get_prop_source, is_prop_source, is_state_source, should_proxy } from '../utils.js';
import { get_value } from './shared/declarations.js';
/**
* @param {VariableDeclaration} node
* @param {ComponentContext} context
*/
export function VariableDeclaration(node, context) {
/** @type {VariableDeclarator[]} */
const declarations = [];
if (context.state.analysis.runes) {
for (const declarator of node.declarations) {
const init = /** @type {Expression} */ (declarator.init);
const rune = get_rune(init, context.state.scope);
if (
!rune ||
rune === '$effect.tracking' ||
rune === '$effect.root' ||
rune === '$inspect' ||
rune === '$inspect.trace' ||
rune === '$state.snapshot' ||
rune === '$host'
) {
declarations.push(/** @type {VariableDeclarator} */ (context.visit(declarator)));
continue;
}
if (rune === '$props.id') {
// skip
continue;
}
if (rune === '$props') {
/** @type {string[]} */
const seen = ['$$slots', '$$events', '$$legacy'];
if (context.state.analysis.custom_element) {
seen.push('$$host');
}
if (declarator.id.type === 'Identifier') {
/** @type {Expression[]} */
const args = [b.id('$$props'), b.array(seen.map((name) => b.literal(name)))];
if (dev) {
// include rest name, so we can provide informative error messages
args.push(b.literal(declarator.id.name));
}
declarations.push(b.declarator(declarator.id, b.call('$.rest_props', ...args)));
// ... (363 more lines)
Domain
Subdomains
Dependencies
Source
Frequently Asked Questions
What does VariableDeclaration.js do?
VariableDeclaration.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 VariableDeclaration.js?
VariableDeclaration.js defines 2 function(s): VariableDeclaration, create_state_declarators.
What does VariableDeclaration.js depend on?
VariableDeclaration.js imports 17 module(s): assert.js, ast.js, builders, declarations.js, extract_paths, get_prop_source, get_rune, get_value, and 9 more.
What files import VariableDeclaration.js?
VariableDeclaration.js is imported by 1 file(s): transform-client.js.
Where is VariableDeclaration.js in the architecture?
VariableDeclaration.js is located at packages/svelte/src/compiler/phases/3-transform/client/visitors/VariableDeclaration.js (domain: Compiler, subdomain: Transformer, directory: packages/svelte/src/compiler/phases/3-transform/client/visitors).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free