Skip to content

Svelte 5 migration script: transform slot usages #13419

Closed
@dummdidumm

Description

@dummdidumm

Describe the problem

Right now the migration function leaves slot usages intact, because the component may not be under the user's control. On the other hand, it transforms slot creations into @render tags. This can create the odd situation where components within your project are transformed by the migration script but not its usage locations.

Describe the proposed solution

Add logic to migrate slot usages in components, e.g. <Component><div slot="foo">..</div></Component> turns into <Component>{#snippet foo()}<div>..</div>{/snippet}</Component> etc.

The tricky part is to figure out when to apply this. I see three options:

  • check component imports: if relative or starting with $ (SvelteKit convention), then assume project component, and therefore do the transformation. Else not
  • provide option to toggle this per component, so migration script can set this more reliably from the outside
  • always do it. This requires us to implement chore: more slot/snippet interop #11619

Option 3 is my current favorite.

Importance

nice to have

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions