Skip to content

Svelte 5: deprecate <svelte:component> #12668

Closed
@Rich-Harris

Description

@Rich-Harris

Describe the problem

See #12646 — we're now in a position to deprecate <svelte:component> if we want.

There are some places where in theory it still makes sense to keep it:

<script>
  import A from './A.svelte';
  import B from './B.svelte';

  let { condition } = $props();
</script>

<svelte:component this={condition ? A : B} />
{#each things as thing}
  <svelte:component this={thing.component} />
{/each}

We could solve these with $derived or @const but maybe that's not as nice. The second one could be solved by treating <thing.component> as a component rather than as an (impossible) element, which is a change we could make separately or at the same time. (It would conflict with Svelte Native's property elements, however.)

Both should be considered for 5.0

Describe the proposed solution

see above

Importance

nice to have

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions