diff --git a/packages/svelte/src/compiler/migrate/index.js b/packages/svelte/src/compiler/migrate/index.js index fb2b04708e..b877d27e54 100644 --- a/packages/svelte/src/compiler/migrate/index.js +++ b/packages/svelte/src/compiler/migrate/index.js @@ -627,7 +627,8 @@ const template = { part.type === 'IfBlock' || part.type === 'KeyBlock' || part.type === 'SnippetBlock' || - part.type === 'Component' + part.type === 'Component' || + part.type === 'SvelteComponent' ) { const indent = state.str.original.substring( state.str.original.lastIndexOf('\n', node.start) + 1, diff --git a/packages/svelte/tests/migrate/samples/svelte-component/input.svelte b/packages/svelte/tests/migrate/samples/svelte-component/input.svelte index c6abfde23e..8d3cbea391 100644 --- a/packages/svelte/tests/migrate/samples/svelte-component/input.svelte +++ b/packages/svelte/tests/migrate/samples/svelte-component/input.svelte @@ -33,6 +33,36 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ''} /> .5 ? $$restProps.heads : $$restProps.tail} prop value="" on:click on:click={()=>''}/> diff --git a/packages/svelte/tests/migrate/samples/svelte-component/output.svelte b/packages/svelte/tests/migrate/samples/svelte-component/output.svelte index 00f4625ac2..de39207d3a 100644 --- a/packages/svelte/tests/migrate/samples/svelte-component/output.svelte +++ b/packages/svelte/tests/migrate/samples/svelte-component/output.svelte @@ -4,7 +4,7 @@ let Component; let fallback; - const SvelteComponent_5 = $derived(Math.random() > .5 ? rest.heads : rest.tail); + const SvelteComponent_10 = $derived(Math.random() > .5 ? rest.heads : rest.tail); @@ -42,9 +42,44 @@ + + + + + + {@const SvelteComponent_5 = comp} + + + + + {@const SvelteComponent_6 = stuff} + + + + + + {@const SvelteComponent_7 = stuff} + + + + + + + {@const SvelteComponent_8 = stuff} + + + + + + + {@const SvelteComponent_9 = stuff} + + + + ''} /> -''}/> +''}/> ''} /> -''} @@ -60,8 +95,8 @@ {#if true} {@const x = {Component}} - {@const SvelteComponent_7 = x['Component']} - + {@const SvelteComponent_12 = x['Component']} + {/if} {#if true} @@ -70,8 +105,8 @@ {/if} {#each [] as component} - {@const SvelteComponent_8 = component} - + {@const SvelteComponent_13 = component} + {/each} {#each [] as Component} @@ -85,20 +120,20 @@ {#each [] as component} {@const comp = component.component} - {@const SvelteComponent_9 = comp} - + {@const SvelteComponent_14 = comp} + {/each} {#await Promise.resolve()} - {@const SvelteComponent_10 = fallback} - + {@const SvelteComponent_15 = fallback} + {:then something} - {@const SvelteComponent_11 = something} - + {@const SvelteComponent_16 = something} + {:catch e} - {@const SvelteComponent_12 = e} - + {@const SvelteComponent_17 = e} + {/await} {#await Promise.resolve() then Something}