diff --git a/.changeset/lucky-geckos-swim.md b/.changeset/lucky-geckos-swim.md new file mode 100644 index 0000000000..c11b3b57fd --- /dev/null +++ b/.changeset/lucky-geckos-swim.md @@ -0,0 +1,5 @@ +--- +'svelte': patch +--- + +fix: remove `bind_prop` in runes mode diff --git a/packages/svelte/src/compiler/phases/3-transform/client/transform-client.js b/packages/svelte/src/compiler/phases/3-transform/client/transform-client.js index 2498f24a69..f9d06ac0d0 100644 --- a/packages/svelte/src/compiler/phases/3-transform/client/transform-client.js +++ b/packages/svelte/src/compiler/phases/3-transform/client/transform-client.js @@ -232,18 +232,6 @@ export function client_component(source, analysis, options) { group_binding_declarations.push(b.const(group.name, b.array([]))); } - // Bind static exports to props so that people can access them with bind:x - const static_bindings = analysis.exports.map(({ name, alias }) => { - return b.stmt( - b.call( - '$.bind_prop', - b.id('$$props'), - b.literal(alias ?? name), - serialize_get_binding(b.id(name), instance_state) - ) - ); - }); - const component_returned_object = analysis.exports.map(({ name, alias }) => { const expression = serialize_get_binding(b.id(name), instance_state); @@ -369,10 +357,25 @@ export function client_component(source, analysis, options) { ...group_binding_declarations, .../** @type {import('estree').Statement[]} */ (instance.body), analysis.runes ? b.empty : b.stmt(b.call('$.init')), - .../** @type {import('estree').Statement[]} */ (template.body), - ...static_bindings + .../** @type {import('estree').Statement[]} */ (template.body) ]); + if (!analysis.runes) { + // Bind static exports to props so that people can access them with bind:x + for (const { name, alias } of analysis.exports) { + component_block.body.push( + b.stmt( + b.call( + '$.bind_prop', + b.id('$$props'), + b.literal(alias ?? name), + serialize_get_binding(b.id(name), instance_state) + ) + ) + ); + } + } + const append_styles = analysis.inject_styles && analysis.css.ast ? () =>