build_inline_component() — svelte Function Reference
Architecture documentation for the build_inline_component() function in component.js from the svelte codebase.
Entity Profile
Dependency Diagram
graph TD 1077eb85_3310_4a9b_f350_d205c6451bd2["build_inline_component()"] 45451ab6_59fb_d444_3c97_cd74d7768f0c["component.js"] 1077eb85_3310_4a9b_f350_d205c6451bd2 -->|defined in| 45451ab6_59fb_d444_3c97_cd74d7768f0c b6acd614_d1a3_2177_6c90_d4c80ec3c1d0["Component()"] b6acd614_d1a3_2177_6c90_d4c80ec3c1d0 -->|calls| 1077eb85_3310_4a9b_f350_d205c6451bd2 b9709eb9_935b_0760_0597_b131ae4296b2["SvelteComponent()"] b9709eb9_935b_0760_0597_b131ae4296b2 -->|calls| 1077eb85_3310_4a9b_f350_d205c6451bd2 02dcb140_7ba6_40e1_cf82_1ed094e9294b["SvelteSelf()"] 02dcb140_7ba6_40e1_cf82_1ed094e9294b -->|calls| 1077eb85_3310_4a9b_f350_d205c6451bd2 9f24c33c_da34_a132_f273_3ffd2f6e5cf8["build_attribute_value()"] 1077eb85_3310_4a9b_f350_d205c6451bd2 -->|calls| 9f24c33c_da34_a132_f273_3ffd2f6e5cf8 126a8308_3b14_c35b_d2d5_a0f33b2939dc["check_blockers()"] 1077eb85_3310_4a9b_f350_d205c6451bd2 -->|calls| 126a8308_3b14_c35b_d2d5_a0f33b2939dc 313a36c6_761f_13b2_e8d6_c0f84cd81a9a["is_element_node()"] 1077eb85_3310_4a9b_f350_d205c6451bd2 -->|calls| 313a36c6_761f_13b2_e8d6_c0f84cd81a9a 7048cd7e_3fd1_ae4c_a573_68a6ebe889e9["render_block()"] 1077eb85_3310_4a9b_f350_d205c6451bd2 -->|calls| 7048cd7e_3fd1_ae4c_a573_68a6ebe889e9 3b2a4fcc_2df2_7057_21b4_4cac59b8df61["is_async()"] 1077eb85_3310_4a9b_f350_d205c6451bd2 -->|calls| 3b2a4fcc_2df2_7057_21b4_4cac59b8df61 style 1077eb85_3310_4a9b_f350_d205c6451bd2 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
packages/svelte/src/compiler/phases/3-transform/server/visitors/shared/component.js lines 14–341
export function build_inline_component(node, expression, context) {
/** @type {Array<Property[] | Expression>} */
const props_and_spreads = [];
/** @type {Array<() => void>} */
const delayed_props = [];
/** @type {Property[]} */
const custom_css_props = [];
/** @type {Record<string, AST.LetDirective[]>} */
const lets = { default: [] };
/**
* Children in the default slot are evaluated in the component scope,
* children in named slots are evaluated in the parent scope
*/
const child_state = {
...context.state,
scope: node.metadata.scopes.default
};
/** @type {Record<string, AST.TemplateNode[]>} */
const children = {};
/**
* If this component has a slot property, it is a named slot within another component. In this case
* the slot scope applies to the component itself, too, and not just its children.
*/
const slot_scope_applies_to_itself = node.attributes.some(
(node) => node.type === 'Attribute' && node.name === 'slot'
);
/**
* Components may have a children prop and also have child nodes. In this case, we assume
* that the child component isn't using render tags yet and pass the slot as $$slots.default.
* We're not doing it for spread attributes, as this would result in too many false positives.
*/
let has_children_prop = false;
/**
* @param {Property} prop
* @param {boolean} [delay]
*/
function push_prop(prop, delay = false) {
const do_push = () => {
const current = props_and_spreads.at(-1);
const current_is_props = Array.isArray(current);
const props = current_is_props ? current : [];
props.push(prop);
if (!current_is_props) {
props_and_spreads.push(props);
}
};
if (delay) {
delayed_props.push(do_push);
} else {
do_push();
}
}
const optimiser = new PromiseOptimiser();
for (const attribute of node.attributes) {
if (attribute.type === 'LetDirective') {
if (!slot_scope_applies_to_itself) {
lets.default.push(attribute);
}
} else if (attribute.type === 'SpreadAttribute') {
let expression = /** @type {Expression} */ (context.visit(attribute));
props_and_spreads.push(optimiser.transform(expression, attribute.metadata.expression));
} else if (attribute.type === 'Attribute') {
const value = build_attribute_value(
attribute.value,
context,
optimiser.transform,
false,
true
);
if (attribute.name.startsWith('--')) {
Domain
Subdomains
Called By
Source
Frequently Asked Questions
What does build_inline_component() do?
build_inline_component() is a function in the svelte codebase, defined in packages/svelte/src/compiler/phases/3-transform/server/visitors/shared/component.js.
Where is build_inline_component() defined?
build_inline_component() is defined in packages/svelte/src/compiler/phases/3-transform/server/visitors/shared/component.js at line 14.
What does build_inline_component() call?
build_inline_component() calls 5 function(s): build_attribute_value, check_blockers, is_async, is_element_node, render_block.
What calls build_inline_component()?
build_inline_component() is called by 3 function(s): Component, SvelteComponent, SvelteSelf.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free