Skip to content

Exported functions don't work on async components #16657

@ottomated

Description

@ottomated

Describe the bug

This component is broken:

<script>
  export function get_name() {
    return 'world';
  }
  // Comment this out and it works
  await Promise.resolve();
</script>

because it defines get_name inside the async function $$body, but calls $.pop in the actual component function. This causes a ReferenceError.

Reproduction

REPL

Logs

Uncaught ReferenceError: get_name is not defined

  in <unknown>
  in __wrapper.svelte
    get get_name playground:output:4786
    get playground:output:2591
    App playground:output:4809

System Info

svelte 5.38.2

Severity

blocking an upgrade

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions