chore: remove snippet and is_async

pull/16762/head
S. Elliott Johnson 1 week ago
parent e3b0f80b7c
commit d6c7f58e69

@ -12,7 +12,6 @@ export function create_fragment(transparent = false) {
transparent, transparent,
dynamic: false, dynamic: false,
has_await: false, has_await: false,
is_async: false,
// name is added later, after we've done scope analysis // name is added later, after we've done scope analysis
hoisted_promises: { name: '', promises: [] } hoisted_promises: { name: '', promises: [] }
} }

@ -306,7 +306,6 @@ export function analyze_module(source, options) {
has_props_rune: false, has_props_rune: false,
options: /** @type {ValidatedCompileOptions} */ (options), options: /** @type {ValidatedCompileOptions} */ (options),
fragment: null, fragment: null,
snippet: null,
title: null, title: null,
boundary: null, boundary: null,
parent_element: null, parent_element: null,
@ -700,7 +699,6 @@ export function analyze_component(root, source, options) {
options, options,
ast_type: ast === instance.ast ? 'instance' : ast === template.ast ? 'template' : 'module', ast_type: ast === instance.ast ? 'instance' : ast === template.ast ? 'template' : 'module',
fragment: ast === template.ast ? ast : null, fragment: ast === template.ast ? ast : null,
snippet: null,
title: null, title: null,
boundary: null, boundary: null,
parent_element: null, parent_element: null,
@ -770,7 +768,6 @@ export function analyze_component(root, source, options) {
analysis, analysis,
options, options,
fragment: ast === template.ast ? ast : null, fragment: ast === template.ast ? ast : null,
snippet: null,
title: null, title: null,
boundary: null, boundary: null,
parent_element: null, parent_element: null,

@ -9,7 +9,6 @@ export interface AnalysisState {
options: ValidatedCompileOptions; options: ValidatedCompileOptions;
ast_type: 'instance' | 'template' | 'module'; ast_type: 'instance' | 'template' | 'module';
fragment: AST.Fragment | null; fragment: AST.Fragment | null;
snippet: AST.SnippetBlock | null;
title: AST.TitleElement | null; title: AST.TitleElement | null;
boundary: AST.SvelteBoundary | null; boundary: AST.SvelteBoundary | null;
/** /**

@ -17,24 +17,21 @@ export function AwaitExpression(node, context) {
context.state.fragment.metadata.has_await = true; context.state.fragment.metadata.has_await = true;
} }
suspend = true; if (context.state.async_hoist_boundary) {
} const len = context.state.async_hoist_boundary.metadata.hoisted_promises.promises.push(
node.argument
);
context.state.analysis.hoisted_promises.set(
node.argument,
b.member(
b.id(context.state.async_hoist_boundary.metadata.hoisted_promises.name),
b.literal(len - 1),
true
)
);
}
// Only set has_await on the boundary when we're in a template expression context suspend = true;
// (not in event handlers or other non-template contexts)
if (context.state.async_hoist_boundary && context.state.expression) {
context.state.async_hoist_boundary.metadata.is_async = true;
const len = context.state.async_hoist_boundary.metadata.hoisted_promises.promises.push(
node.argument
);
context.state.analysis.hoisted_promises.set(
node.argument,
b.member(
b.id(context.state.async_hoist_boundary.metadata.hoisted_promises.name),
b.literal(len - 1),
true
)
);
} }
if (context.state.title) { if (context.state.title) {

@ -26,7 +26,6 @@ export function SnippetBlock(node, context) {
context.next({ context.next({
...context.state, ...context.state,
parent_element: null, parent_element: null,
snippet: node,
async_hoist_boundary: node.body async_hoist_boundary: node.body
}); });

@ -52,11 +52,7 @@ export function Fragment(node, context) {
b.stmt( b.stmt(
b.call( b.call(
'$$payload.child', '$$payload.child',
b.arrow( b.arrow([b.id('$$payload')], b.block(build_template(state.template)), true)
[b.id('$$payload')],
b.block(build_template(state.template)),
node.metadata.is_async
)
) )
) )
]); ]);

@ -57,10 +57,6 @@ export namespace AST {
*/ */
dynamic: boolean; dynamic: boolean;
has_await: boolean; has_await: boolean;
/**
* True when this fragment has a top-level `await` expression.
*/
is_async: boolean;
hoisted_promises: { name: string; promises: Expression[] }; hoisted_promises: { name: string; promises: Expression[] };
}; };
} }

Loading…
Cancel
Save