Skip to content

fix: don't blank css on migration error #13703

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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>