remove async_hoist_boundary

pull/16757/head
Rich Harris 1 week ago
parent 48b766cc46
commit 9a273c6af2

@ -309,8 +309,7 @@ export function analyze_module(source, options) {
title: null, title: null,
boundary: null, boundary: null,
parent_element: null, parent_element: null,
reactive_statement: null, reactive_statement: null
async_hoist_boundary: null
}, },
visitors visitors
); );
@ -709,8 +708,7 @@ export function analyze_component(root, source, options) {
expression: null, expression: null,
state_fields: new Map(), state_fields: new Map(),
function_depth: scope.function_depth, function_depth: scope.function_depth,
reactive_statement: null, reactive_statement: null
async_hoist_boundary: ast === template.ast ? ast : null
}; };
walk(/** @type {AST.SvelteNode} */ (ast), state, visitors); walk(/** @type {AST.SvelteNode} */ (ast), state, visitors);
@ -779,8 +777,7 @@ export function analyze_component(root, source, options) {
component_slots: new Set(), component_slots: new Set(),
expression: null, expression: null,
state_fields: new Map(), state_fields: new Map(),
function_depth: scope.function_depth, function_depth: scope.function_depth
async_hoist_boundary: ast === template.ast ? ast : null
}; };
walk(/** @type {AST.SvelteNode} */ (ast), state, visitors); walk(/** @type {AST.SvelteNode} */ (ast), state, visitors);

@ -11,14 +11,6 @@ export interface AnalysisState {
fragment: AST.Fragment | null; fragment: AST.Fragment | null;
title: AST.TitleElement | null; title: AST.TitleElement | null;
boundary: AST.SvelteBoundary | null; boundary: AST.SvelteBoundary | null;
/**
* The "anchor" fragment for any hoisted promises. This is the root fragment when
* walking starts and until another boundary fragment is encountered, like a
* consequent or alternate of an `#if` or `#each` block. When this fragment is emitted
* during server transformation, the promise expressions will be hoisted out of the fragment
* and placed right above it in an array.
*/
async_hoist_boundary: AST.Fragment | null;
/** /**
* Tag name of the parent element. `null` if the parent is `svelte:element`, `#snippet`, a component or the root. * Tag name of the parent element. `null` if the parent is `svelte:element`, `#snippet`, a component or the root.
* Parent doesn't necessarily mean direct path predecessor because there could be `#each`, `#if` etc in-between. * Parent doesn't necessarily mean direct path predecessor because there could be `#each`, `#if` etc in-between.

@ -44,22 +44,7 @@ export function AwaitBlock(node, context) {
// this one doesn't get the new state because it still hoists to the existing scope // this one doesn't get the new state because it still hoists to the existing scope
context.visit(node.expression, { ...context.state, expression: node.metadata.expression }); context.visit(node.expression, { ...context.state, expression: node.metadata.expression });
if (node.pending) { if (node.pending) context.visit(node.pending);
context.visit(node.pending, { if (node.then) context.visit(node.then);
...context.state, if (node.catch) context.visit(node.catch);
async_hoist_boundary: node.pending
});
}
if (node.then) {
context.visit(node.then, {
...context.state,
async_hoist_boundary: node.then
});
}
if (node.catch) {
context.visit(node.catch, {
...context.state,
async_hoist_boundary: node.catch
});
}
} }

@ -35,16 +35,10 @@ export function EachBlock(node, context) {
scope: /** @type {Scope} */ (context.state.scope.parent) scope: /** @type {Scope} */ (context.state.scope.parent)
}); });
context.visit(node.body, { context.visit(node.body);
...context.state,
async_hoist_boundary: node.body
});
if (node.key) context.visit(node.key); if (node.key) context.visit(node.key);
if (node.fallback) { if (node.fallback) {
context.visit(node.fallback, { context.visit(node.fallback);
...context.state,
async_hoist_boundary: node.fallback
});
} }
if (!context.state.analysis.runes) { if (!context.state.analysis.runes) {

@ -22,14 +22,8 @@ export function IfBlock(node, context) {
expression: node.metadata.expression expression: node.metadata.expression
}); });
context.visit(node.consequent, { context.visit(node.consequent);
...context.state,
async_hoist_boundary: node.consequent
});
if (node.alternate) { if (node.alternate) {
context.visit(node.alternate, { context.visit(node.alternate);
...context.state,
async_hoist_boundary: node.alternate
});
} }
} }

@ -17,9 +17,5 @@ export function KeyBlock(node, context) {
mark_subtree_dynamic(context.path); mark_subtree_dynamic(context.path);
context.visit(node.expression, { ...context.state, expression: node.metadata.expression }); context.visit(node.expression, { ...context.state, expression: node.metadata.expression });
context.visit(node.fragment);
context.visit(node.fragment, {
...context.state,
async_hoist_boundary: node.fragment
});
} }

@ -23,11 +23,7 @@ export function SnippetBlock(node, context) {
} }
} }
context.next({ context.next({ ...context.state, parent_element: null });
...context.state,
parent_element: null,
async_hoist_boundary: node.body
});
const can_hoist = const can_hoist =
context.path.length === 1 && context.path.length === 1 &&

@ -34,9 +34,5 @@ export function SvelteBoundary(node, context) {
) )
) ?? null; ) ?? null;
context.next({ context.next({ ...context.state, boundary: node });
...context.state,
boundary: node,
async_hoist_boundary: node.fragment
});
} }

Loading…
Cancel
Save