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

pull/13704/head
Paolo Ricciuti 3 months ago committed by GitHub
parent c73c683ecd
commit e43176906f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -0,0 +1,5 @@
---
'svelte': patch
---
fix: don't blank css on migration error

@ -34,6 +34,7 @@ let has_migration_task = false;
* @returns {{ code: string; }} * @returns {{ code: string; }}
*/ */
export function migrate(source, { filename } = {}) { export function migrate(source, { filename } = {}) {
let og_source = source;
try { try {
has_migration_task = false; has_migration_task = false;
// Blank CSS, could contain SCSS or similar that needs a preprocessor. // 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); console.error('Error while migrating Svelte code', e);
has_migration_task = true; has_migration_task = true;
return { 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 { } finally {
if (has_migration_task) { if (has_migration_task) {

@ -0,0 +1,11 @@
<script>
export let error = true;
</script>
{$$props}
<style lang="postcss">
div{
color: red;
}
</style>

@ -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>
Loading…
Cancel
Save