diff --git a/.changeset/cool-apes-confess.md b/.changeset/cool-apes-confess.md
new file mode 100644
index 0000000000..6142d430ff
--- /dev/null
+++ b/.changeset/cool-apes-confess.md
@@ -0,0 +1,5 @@
+---
+'svelte': patch
+---
+
+fix: ensure inserted code is preserved during migration
diff --git a/packages/svelte/src/compiler/migrate/index.js b/packages/svelte/src/compiler/migrate/index.js
index 5c2c1fb484..42727ea212 100644
--- a/packages/svelte/src/compiler/migrate/index.js
+++ b/packages/svelte/src/compiler/migrate/index.js
@@ -273,7 +273,7 @@ export function migrate(source, { filename } = {}) {
const { start, end } = get_node_range(source, node);
str.appendLeft(end, '\n');
str.move(start, end, /** @type {number} */ (parsed.instance?.content.end));
- str.remove(start - (source[start - 2] === '\r' ? 2 : 1), start);
+ str.update(start - (source[start - 2] === '\r' ? 2 : 1), start, '');
}
}
diff --git a/packages/svelte/tests/migrate/samples/reactive-statements-reorder-not-deleting-additions/input.svelte b/packages/svelte/tests/migrate/samples/reactive-statements-reorder-not-deleting-additions/input.svelte
new file mode 100644
index 0000000000..2b90ce8212
--- /dev/null
+++ b/packages/svelte/tests/migrate/samples/reactive-statements-reorder-not-deleting-additions/input.svelte
@@ -0,0 +1,12 @@
+
\ No newline at end of file
diff --git a/packages/svelte/tests/migrate/samples/reactive-statements-reorder-not-deleting-additions/output.svelte b/packages/svelte/tests/migrate/samples/reactive-statements-reorder-not-deleting-additions/output.svelte
new file mode 100644
index 0000000000..dffe4308fb
--- /dev/null
+++ b/packages/svelte/tests/migrate/samples/reactive-statements-reorder-not-deleting-additions/output.svelte
@@ -0,0 +1,15 @@
+
\ No newline at end of file