diff --git a/.changeset/healthy-bees-wave.md b/.changeset/healthy-bees-wave.md new file mode 100644 index 0000000000..6a31a94e3a --- /dev/null +++ b/.changeset/healthy-bees-wave.md @@ -0,0 +1,5 @@ +--- +'svelte': patch +--- + +fix: don't blank css on migration error diff --git a/packages/svelte/src/compiler/migrate/index.js b/packages/svelte/src/compiler/migrate/index.js index b0867766e3..f2b6977ea1 100644 --- a/packages/svelte/src/compiler/migrate/index.js +++ b/packages/svelte/src/compiler/migrate/index.js @@ -34,6 +34,7 @@ let has_migration_task = false; * @returns {{ code: string; }} */ export function migrate(source, { filename } = {}) { + let og_source = source; try { has_migration_task = false; // Blank CSS, could contain SCSS or similar that needs a preprocessor. @@ -303,7 +304,7 @@ export function migrate(source, { filename } = {}) { console.error('Error while migrating Svelte code', e); has_migration_task = true; return { - code: `\n${source}` + code: `\n${og_source}` }; } finally { if (has_migration_task) { diff --git a/packages/svelte/tests/migrate/samples/not-blank-css-if-error/input.svelte b/packages/svelte/tests/migrate/samples/not-blank-css-if-error/input.svelte new file mode 100644 index 0000000000..c31b74df34 --- /dev/null +++ b/packages/svelte/tests/migrate/samples/not-blank-css-if-error/input.svelte @@ -0,0 +1,11 @@ + + +{$$props} + + \ No newline at end of file diff --git a/packages/svelte/tests/migrate/samples/not-blank-css-if-error/output.svelte b/packages/svelte/tests/migrate/samples/not-blank-css-if-error/output.svelte new file mode 100644 index 0000000000..a62a6d4d90 --- /dev/null +++ b/packages/svelte/tests/migrate/samples/not-blank-css-if-error/output.svelte @@ -0,0 +1,12 @@ + + + +{$$props} + + \ No newline at end of file