feat: async fragments

#16542

Closing issue

Pull request

Merged
O
Ocean-OS
Aug 2, 2025, 5:41 AM

Currently, not every part of your component can be async— child fragments can't be. A fragment is the children inside of a block, such as an {#if } block. Most fragments are compiled to synchronous functions. Since template expressions are individually compiled to functions that are either async or sync depending on their values, they can be async inside synchronous fragments. However, other things, such as {@const }, can't be async, since you can't have await expressions inside synchronous functions. This fixes that. Additionally, this makes certain features, such as variable declarations in markup, much easier to implement.

Closes #16462 Supersedes #16463

Before submitting the PR, please make sure you do the following

  • It's really useful if your PR references an issue where it is discussed ahead of time. In many cases, features are absent for a reason. For large changes, please create an RFC: https://github.com/sveltejs/rfcs
  • Prefix your PR title with feat:, fix:, chore:, or docs:.
  • This message body should clearly illustrate what problems it solves.
  • Ideally, include a test that fails without this PR but passes with it.
  • If this PR changes code within packages/svelte/src, add a changeset (npx changeset).

Tests and linting

  • Run the tests with pnpm test and lint the project with pnpm lint

Info

Merged at Aug 6, 2025, 5:53 PM
Merged by Rich-Harris
Assignees None
Reviewers None
Labels None
Milestone None