Skip to content

Commit c5fa0b4

Browse files
fix: missing space when importing run as in migration (#13361)
* fix: missing space when importing run as in migration * chore: add test
1 parent bc2d30c commit c5fa0b4

File tree

3 files changed

+37
-1
lines changed

3 files changed

+37
-1
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ export function migrate(source) {
7171
state = { ...state, scope: analysis.template.scope };
7272
walk(parsed.fragment, state, template);
7373

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

7777
if (state.props.length > 0 || analysis.uses_rest_props || analysis.uses_props) {
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<script>
2+
let count = 0;
3+
let run = true;
4+
$: console.log(count);
5+
$: if (count > 10 && run) {
6+
alert('too high')
7+
}
8+
$: {
9+
console.log('foo');
10+
if (x) break $;
11+
console.log('bar');
12+
}
13+
$: $count = 1;
14+
</script>
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<script>
2+
import { run as run_1 } from 'svelte/legacy';
3+
4+
let count = 0;
5+
let run = true;
6+
run_1(() => {
7+
console.log(count);
8+
});
9+
run_1(() => {
10+
if (count > 10 && run) {
11+
alert('too high')
12+
}
13+
});
14+
run_1(() => {
15+
console.log('foo');
16+
if (x) return;
17+
console.log('bar');
18+
});
19+
run_1(() => {
20+
$count = 1;
21+
});
22+
</script>

0 commit comments

Comments
 (0)