From f632b2a944f34a05182aebb39a877ff712089ea3 Mon Sep 17 00:00:00 2001 From: Caique Torres <56696506+caiquetorres@users.noreply.github.com> Date: Fri, 19 Apr 2024 14:01:07 -0300 Subject: [PATCH] feat: checking for runes when generating js code for object mutations (#11243) --- .changeset/sixty-pandas-rush.md | 5 +++++ .../compiler/phases/3-transform/client/visitors/global.js | 2 ++ 2 files changed, 7 insertions(+) create mode 100644 .changeset/sixty-pandas-rush.md diff --git a/.changeset/sixty-pandas-rush.md b/.changeset/sixty-pandas-rush.md new file mode 100644 index 0000000000..0bae18c06c --- /dev/null +++ b/.changeset/sixty-pandas-rush.md @@ -0,0 +1,5 @@ +--- +"svelte": patch +--- + +fix: optimize object property mutations in compilation diff --git a/packages/svelte/src/compiler/phases/3-transform/client/visitors/global.js b/packages/svelte/src/compiler/phases/3-transform/client/visitors/global.js index c299dd99ef..811407b35b 100644 --- a/packages/svelte/src/compiler/phases/3-transform/client/visitors/global.js +++ b/packages/svelte/src/compiler/phases/3-transform/client/visitors/global.js @@ -105,6 +105,8 @@ export const global_visitors = { if (serialized_assignment === assignment) { // No change to output -> nothing to transform -> we can keep the original update expression return next(); + } else if (context.state.analysis.runes) { + return serialized_assignment; } else { /** @type {import('estree').Statement[]} */ let statements;