Skip to content

Commit

Permalink
fix: don't blank css on migration error (#13703)
Browse files Browse the repository at this point in the history
  • Loading branch information
paoloricciuti authored Oct 19, 2024
1 parent c73c683 commit e431769
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/healthy-bees-wave.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'svelte': patch
---

fix: don't blank css on migration error
3 changes: 2 additions & 1 deletion packages/svelte/src/compiler/migrate/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -303,7 +304,7 @@ export function migrate(source, { filename } = {}) {
console.error('Error while migrating Svelte code', e);
has_migration_task = true;
return {
code: `<!-- @migration-task Error while migrating Svelte code: ${/** @type {any} */ (e).message} -->\n${source}`
code: `<!-- @migration-task Error while migrating Svelte code: ${/** @type {any} */ (e).message} -->\n${og_source}`
};
} finally {
if (has_migration_task) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<script>
export let error = true;
</script>

{$$props}

<style lang="postcss">
div{
color: red;
}
</style>
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<!-- @migration-task Error while migrating Svelte code: $$props is used together with named props in a way that cannot be automatically migrated. -->
<script>
export let error = true;
</script>

{$$props}

<style lang="postcss">
div{
color: red;
}
</style>

0 comments on commit e431769

Please sign in to comment.