Skip to content

Commit 710c3a6

Browse files
committed
fix: don't blank css on migration error
1 parent c73c683 commit 710c3a6

File tree

4 files changed

+30
-1
lines changed

4 files changed

+30
-1
lines changed

.changeset/healthy-bees-wave.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'svelte': patch
3+
---
4+
5+
fix: don't blank css on migration error

packages/svelte/src/compiler/migrate/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ let has_migration_task = false;
3434
* @returns {{ code: string; }}
3535
*/
3636
export function migrate(source, { filename } = {}) {
37+
let og_source = source;
3738
try {
3839
has_migration_task = false;
3940
// Blank CSS, could contain SCSS or similar that needs a preprocessor.
@@ -303,7 +304,7 @@ export function migrate(source, { filename } = {}) {
303304
console.error('Error while migrating Svelte code', e);
304305
has_migration_task = true;
305306
return {
306-
code: `<!-- @migration-task Error while migrating Svelte code: ${/** @type {any} */ (e).message} -->\n${source}`
307+
code: `<!-- @migration-task Error while migrating Svelte code: ${/** @type {any} */ (e).message} -->\n${og_source}`
307308
};
308309
} finally {
309310
if (has_migration_task) {
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<script>
2+
export let error = true;
3+
</script>
4+
5+
{$$props}
6+
7+
<style lang="postcss">
8+
div{
9+
color: red;
10+
}
11+
</style>
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<!-- @migration-task Error while migrating Svelte code: $$props is used together with named props in a way that cannot be automatically migrated. -->
2+
<script>
3+
export let error = true;
4+
</script>
5+
6+
{$$props}
7+
8+
<style lang="postcss">
9+
div{
10+
color: red;
11+
}
12+
</style>

0 commit comments

Comments
 (0)