diff --git a/.changeset/gorgeous-jars-sparkle.md b/.changeset/gorgeous-jars-sparkle.md new file mode 100644 index 000000000000..54b4bd9f5f2a --- /dev/null +++ b/.changeset/gorgeous-jars-sparkle.md @@ -0,0 +1,5 @@ +--- +'@sveltejs/kit': patch +--- + +fix: Svelte 5 - ignore `binding_non_reactive` warning in generated root component (you also need to update to `svelte@5.0.0-next.204`) diff --git a/packages/kit/src/core/sync/write_root.js b/packages/kit/src/core/sync/write_root.js index af8cf889bc32..284f4a61dcdc 100644 --- a/packages/kit/src/core/sync/write_root.js +++ b/packages/kit/src/core/sync/write_root.js @@ -21,15 +21,20 @@ export function write_root(manifest_data, output) { let l = max_depth; - let pyramid = ``; + let pyramid = dedent` + ${isSvelte5Plus() ? '' : ''} + + `; while (l--) { pyramid = dedent` {#if constructors[${l + 1}]} + ${isSvelte5Plus() ? '' : ''} ${pyramid} {:else} + ${isSvelte5Plus() ? '' : ''} {/if} `; diff --git a/packages/kit/test/apps/basics/test/client.test.js b/packages/kit/test/apps/basics/test/client.test.js index a0899a2c239f..1249b95c4930 100644 --- a/packages/kit/test/apps/basics/test/client.test.js +++ b/packages/kit/test/apps/basics/test/client.test.js @@ -1198,3 +1198,19 @@ test.describe('INP', () => { expect(time).toBeLessThan(400); }); }); + +test.describe('binding_property_non_reactive warn', () => { + test('warning is not thrown from the root of svelte', async ({ page }) => { + let is_warning_thrown = false; + page.on('console', (m) => { + if ( + m.type() === 'warn' && + m.text().includes('binding_property_non_reactive `bind:this={components[0]}`') + ) { + is_warning_thrown = true; + } + }); + await page.goto('/'); + expect(is_warning_thrown).toBeFalsy(); + }); +});