From d6c7f58e69a0e567af8336c94f7547193165dc16 Mon Sep 17 00:00:00 2001 From: "S. Elliott Johnson" Date: Thu, 11 Sep 2025 09:44:28 -0600 Subject: [PATCH] chore: remove snippet and is_async --- .../compiler/phases/1-parse/utils/create.js | 1 - .../src/compiler/phases/2-analyze/index.js | 3 -- .../src/compiler/phases/2-analyze/types.d.ts | 1 - .../2-analyze/visitors/AwaitExpression.js | 31 +++++++++---------- .../phases/2-analyze/visitors/SnippetBlock.js | 1 - .../3-transform/server/visitors/Fragment.js | 6 +--- .../svelte/src/compiler/types/template.d.ts | 4 --- 7 files changed, 15 insertions(+), 32 deletions(-) diff --git a/packages/svelte/src/compiler/phases/1-parse/utils/create.js b/packages/svelte/src/compiler/phases/1-parse/utils/create.js index efe578fef2..1a6f15aee7 100644 --- a/packages/svelte/src/compiler/phases/1-parse/utils/create.js +++ b/packages/svelte/src/compiler/phases/1-parse/utils/create.js @@ -12,7 +12,6 @@ export function create_fragment(transparent = false) { transparent, dynamic: false, has_await: false, - is_async: false, // name is added later, after we've done scope analysis hoisted_promises: { name: '', promises: [] } } diff --git a/packages/svelte/src/compiler/phases/2-analyze/index.js b/packages/svelte/src/compiler/phases/2-analyze/index.js index d3f759a10f..c1d96daad4 100644 --- a/packages/svelte/src/compiler/phases/2-analyze/index.js +++ b/packages/svelte/src/compiler/phases/2-analyze/index.js @@ -306,7 +306,6 @@ export function analyze_module(source, options) { has_props_rune: false, options: /** @type {ValidatedCompileOptions} */ (options), fragment: null, - snippet: null, title: null, boundary: null, parent_element: null, @@ -700,7 +699,6 @@ export function analyze_component(root, source, options) { options, ast_type: ast === instance.ast ? 'instance' : ast === template.ast ? 'template' : 'module', fragment: ast === template.ast ? ast : null, - snippet: null, title: null, boundary: null, parent_element: null, @@ -770,7 +768,6 @@ export function analyze_component(root, source, options) { analysis, options, fragment: ast === template.ast ? ast : null, - snippet: null, title: null, boundary: null, parent_element: null, diff --git a/packages/svelte/src/compiler/phases/2-analyze/types.d.ts b/packages/svelte/src/compiler/phases/2-analyze/types.d.ts index 45523975dd..a5b734f187 100644 --- a/packages/svelte/src/compiler/phases/2-analyze/types.d.ts +++ b/packages/svelte/src/compiler/phases/2-analyze/types.d.ts @@ -9,7 +9,6 @@ export interface AnalysisState { options: ValidatedCompileOptions; ast_type: 'instance' | 'template' | 'module'; fragment: AST.Fragment | null; - snippet: AST.SnippetBlock | null; title: AST.TitleElement | null; boundary: AST.SvelteBoundary | null; /** diff --git a/packages/svelte/src/compiler/phases/2-analyze/visitors/AwaitExpression.js b/packages/svelte/src/compiler/phases/2-analyze/visitors/AwaitExpression.js index c9d06e3589..e6777ec48c 100644 --- a/packages/svelte/src/compiler/phases/2-analyze/visitors/AwaitExpression.js +++ b/packages/svelte/src/compiler/phases/2-analyze/visitors/AwaitExpression.js @@ -17,24 +17,21 @@ export function AwaitExpression(node, context) { 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 - // (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 - ) - ); + suspend = true; } if (context.state.title) { diff --git a/packages/svelte/src/compiler/phases/2-analyze/visitors/SnippetBlock.js b/packages/svelte/src/compiler/phases/2-analyze/visitors/SnippetBlock.js index 86951fd2a6..d0554856e9 100644 --- a/packages/svelte/src/compiler/phases/2-analyze/visitors/SnippetBlock.js +++ b/packages/svelte/src/compiler/phases/2-analyze/visitors/SnippetBlock.js @@ -26,7 +26,6 @@ export function SnippetBlock(node, context) { context.next({ ...context.state, parent_element: null, - snippet: node, async_hoist_boundary: node.body }); diff --git a/packages/svelte/src/compiler/phases/3-transform/server/visitors/Fragment.js b/packages/svelte/src/compiler/phases/3-transform/server/visitors/Fragment.js index 1069459e3e..74d130e0db 100644 --- a/packages/svelte/src/compiler/phases/3-transform/server/visitors/Fragment.js +++ b/packages/svelte/src/compiler/phases/3-transform/server/visitors/Fragment.js @@ -52,11 +52,7 @@ export function Fragment(node, context) { b.stmt( b.call( '$$payload.child', - b.arrow( - [b.id('$$payload')], - b.block(build_template(state.template)), - node.metadata.is_async - ) + b.arrow([b.id('$$payload')], b.block(build_template(state.template)), true) ) ) ]); diff --git a/packages/svelte/src/compiler/types/template.d.ts b/packages/svelte/src/compiler/types/template.d.ts index 4efeeb3bfd..aa989898fa 100644 --- a/packages/svelte/src/compiler/types/template.d.ts +++ b/packages/svelte/src/compiler/types/template.d.ts @@ -57,10 +57,6 @@ export namespace AST { */ dynamic: boolean; has_await: boolean; - /** - * True when this fragment has a top-level `await` expression. - */ - is_async: boolean; hoisted_promises: { name: string; promises: Expression[] }; }; }