Skip to content

Commit

Permalink
fix: missing space when importing run as in migration (#13361)
Browse files Browse the repository at this point in the history
* fix: missing space when importing run as in migration

* chore: add test
  • Loading branch information
paoloricciuti authored Sep 21, 2024
1 parent bc2d30c commit c5fa0b4
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/svelte/src/compiler/migrate/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export function migrate(source) {
state = { ...state, scope: analysis.template.scope };
walk(parsed.fragment, state, template);

const run_import = `import { run${state.run_name === 'run' ? '' : `as ${state.run_name}`} } from 'svelte/legacy';`;
const run_import = `import { run${state.run_name === 'run' ? '' : ` as ${state.run_name}`} } from 'svelte/legacy';`;
let added_legacy_import = false;

if (state.props.length > 0 || analysis.uses_rest_props || analysis.uses_props) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<script>
let count = 0;
let run = true;
$: console.log(count);
$: if (count > 10 && run) {
alert('too high')
}
$: {
console.log('foo');
if (x) break $;
console.log('bar');
}
$: $count = 1;
</script>
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<script>
import { run as run_1 } from 'svelte/legacy';
let count = 0;
let run = true;
run_1(() => {
console.log(count);
});
run_1(() => {
if (count > 10 && run) {
alert('too high')
}
});
run_1(() => {
console.log('foo');
if (x) return;
console.log('bar');
});
run_1(() => {
$count = 1;
});
</script>

0 comments on commit c5fa0b4

Please sign in to comment.