Skip to content

Commit 6ecdba5

Browse files
committed
only wrap in iife if necessary
1 parent 2ddb117 commit 6ecdba5

File tree

2 files changed

+6
-2
lines changed
  • packages/svelte

2 files changed

+6
-2
lines changed

packages/svelte/src/compiler/phases/3-transform/shared/assignments.js

+4
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,10 @@ export function visit_assignment_expression(node, context, build_assignment) {
5454
block.body.push(b.return(rhs));
5555
}
5656

57+
if (is_standalone && !should_cache) {
58+
return block;
59+
}
60+
5761
const iife = b.arrow(should_cache ? [rhs] : [], block);
5862

5963
const iife_is_async =

packages/svelte/tests/snapshot/samples/destructured-assignments/_expected/client/index.svelte.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@ let c = 3;
77
let d = 4;
88

99
export function update(array) {
10-
(() => {
10+
{
1111
let [$$1, $$2] = array;
1212

1313
$.set(a, $$1, true);
1414
$.set(b, $$2, true);
15-
})();
15+
};
1616

1717
[c, d] = array;
1818
}

0 commit comments

Comments
 (0)