Home / File/ BlockStatement.js — svelte Source File

BlockStatement.js — svelte Source File

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

File javascript Compiler Transformer 3 imports 1 dependents 1 functions

Entity Profile

Dependency Diagram

graph LR
  23a1c53f_df53_154c_a2d9_3e0efa9bef15["BlockStatement.js"]
  1a53d630_ca18_6783_bd92_8c72517a9306["declarations.js"]
  23a1c53f_df53_154c_a2d9_3e0efa9bef15 --> 1a53d630_ca18_6783_bd92_8c72517a9306
  fb41e547_07c8_cc9a_e227_3f08aad6d1f5["add_state_transformers"]
  23a1c53f_df53_154c_a2d9_3e0efa9bef15 --> fb41e547_07c8_cc9a_e227_3f08aad6d1f5
  95c28355_f14c_c3cd_5a03_d5a53ca255bc["builders"]
  23a1c53f_df53_154c_a2d9_3e0efa9bef15 --> 95c28355_f14c_c3cd_5a03_d5a53ca255bc
  7665e008_f37d_b860_a594_f2539a66af4e["transform-client.js"]
  7665e008_f37d_b860_a594_f2539a66af4e --> 23a1c53f_df53_154c_a2d9_3e0efa9bef15
  style 23a1c53f_df53_154c_a2d9_3e0efa9bef15 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

/** @import { ArrowFunctionExpression, BlockStatement, Expression, FunctionDeclaration, FunctionExpression, Statement } from 'estree' */
/** @import { ComponentContext } from '../types' */
import { add_state_transformers } from './shared/declarations.js';
import * as b from '#compiler/builders';

/**
 * @param {BlockStatement} node
 * @param {ComponentContext} context
 */
export function BlockStatement(node, context) {
	add_state_transformers(context);
	const tracing = context.state.scope.tracing;

	if (tracing !== null) {
		const parent =
			/** @type {ArrowFunctionExpression | FunctionDeclaration | FunctionExpression} */ (
				context.path.at(-1)
			);

		const is_async = parent.async;

		const call = b.call(
			'$.trace',
			/** @type {Expression} */ (tracing),
			b.thunk(b.block(node.body.map((n) => /** @type {Statement} */ (context.visit(n)))), is_async)
		);

		return b.block([b.return(is_async ? b.await(call) : call)]);
	}

	context.next();
}

Domain

Subdomains

Functions

Frequently Asked Questions

What does BlockStatement.js do?
BlockStatement.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 BlockStatement.js?
BlockStatement.js defines 1 function(s): BlockStatement.
What does BlockStatement.js depend on?
BlockStatement.js imports 3 module(s): add_state_transformers, builders, declarations.js.
What files import BlockStatement.js?
BlockStatement.js is imported by 1 file(s): transform-client.js.
Where is BlockStatement.js in the architecture?
BlockStatement.js is located at packages/svelte/src/compiler/phases/3-transform/client/visitors/BlockStatement.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