SvelteBoundary.js — svelte Source File
Architecture documentation for SvelteBoundary.js, a javascript file in the svelte codebase. 2 imports, 1 dependents.
Entity Profile
Dependency Diagram
graph LR 4b2dc6b5_eb70_5a84_22a0_c06f14719b60["SvelteBoundary.js"] 62f818c8_e890_17ed_5ec1_92f953d4a7a6["state.js"] 4b2dc6b5_eb70_5a84_22a0_c06f14719b60 --> 62f818c8_e890_17ed_5ec1_92f953d4a7a6 95c28355_f14c_c3cd_5a03_d5a53ca255bc["builders"] 4b2dc6b5_eb70_5a84_22a0_c06f14719b60 --> 95c28355_f14c_c3cd_5a03_d5a53ca255bc 7665e008_f37d_b860_a594_f2539a66af4e["transform-client.js"] 7665e008_f37d_b860_a594_f2539a66af4e --> 4b2dc6b5_eb70_5a84_22a0_c06f14719b60 style 4b2dc6b5_eb70_5a84_22a0_c06f14719b60 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
/** @import { BlockStatement, Statement, Expression, VariableDeclaration } from 'estree' */
/** @import { AST } from '#compiler' */
/** @import { ComponentContext } from '../types' */
import { dev } from '../../../../state.js';
import * as b from '#compiler/builders';
/**
* @param {AST.SvelteBoundary} node
* @param {ComponentContext} context
*/
export function SvelteBoundary(node, context) {
const props = b.object([]);
for (const attribute of node.attributes) {
if (attribute.type !== 'Attribute' || attribute.value === true) {
// these can't exist, because they would have caused validation
// to fail, but typescript doesn't know that
continue;
}
const chunk = Array.isArray(attribute.value)
? /** @type {AST.ExpressionTag} */ (attribute.value[0])
: attribute.value;
const expression = /** @type {Expression} */ (context.visit(chunk.expression, context.state));
if (chunk.metadata.expression.has_state) {
props.properties.push(b.get(attribute.name, [b.return(expression)]));
} else {
props.properties.push(b.init(attribute.name, expression));
}
}
const nodes = [];
/** @type {Statement[]} */
const const_tags = [];
/** @type {Statement[]} */
const hoisted = [];
let has_const = false;
// const tags need to live inside the boundary, but might also be referenced in hoisted snippets.
// to resolve this we cheat: we duplicate const tags inside snippets
// We'll revert this behavior in the future, it was a mistake to allow this (Component snippets also don't do this).
for (const child of node.fragment.nodes) {
if (child.type === 'ConstTag') {
has_const = true;
if (!context.state.options.experimental.async) {
context.visit(child, {
...context.state,
consts: const_tags,
scope: context.state.scopes.get(node.fragment) ?? context.state.scope
});
}
}
}
for (const child of node.fragment.nodes) {
// ... (67 more lines)
Domain
Subdomains
Functions
Dependencies
- builders
- state.js
Source
Frequently Asked Questions
What does SvelteBoundary.js do?
SvelteBoundary.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 SvelteBoundary.js?
SvelteBoundary.js defines 1 function(s): SvelteBoundary.
What does SvelteBoundary.js depend on?
SvelteBoundary.js imports 2 module(s): builders, state.js.
What files import SvelteBoundary.js?
SvelteBoundary.js is imported by 1 file(s): transform-client.js.
Where is SvelteBoundary.js in the architecture?
SvelteBoundary.js is located at packages/svelte/src/compiler/phases/3-transform/client/visitors/SvelteBoundary.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