Skip to content

Commit 9ab08aa

Browse files
committed
fix
1 parent ccc9939 commit 9ab08aa

File tree

1 file changed

+22
-20
lines changed
  • packages/svelte/src/compiler/phases/3-transform/client/visitors

1 file changed

+22
-20
lines changed

packages/svelte/src/compiler/phases/3-transform/client/visitors/Program.js

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -143,27 +143,29 @@ export function Program(node, context) {
143143
const transformed = /** @type {Program['body'][number]} */ (context.visit(node.body[i]));
144144
body.push(transformed);
145145
}
146-
let offset = 0;
147-
for (const chunk of context.state.parallelized_chunks) {
148-
if (chunk.declarators.length === 1) {
149-
const declarator = chunk.declarators[0];
150-
body.splice(
151-
chunk.position + offset,
152-
0,
153-
b.declaration(chunk.kind, [
154-
b.declarator(declarator.id, b.call(b.await(b.call('$.save', declarator.init))))
155-
])
156-
);
157-
} else {
158-
const pattern = b.array_pattern(chunk.declarators.map(({ id }) => id));
159-
const init = b.call('$.all', ...chunk.declarators.map(({ init }) => init));
160-
body.splice(
161-
chunk.position + offset,
162-
0,
163-
b.declaration(chunk.kind, [b.declarator(pattern, b.await(init))])
164-
);
146+
if (context.state.parallelized_chunks) {
147+
let offset = 0;
148+
for (const chunk of context.state.parallelized_chunks) {
149+
if (chunk.declarators.length === 1) {
150+
const declarator = chunk.declarators[0];
151+
body.splice(
152+
chunk.position + offset,
153+
0,
154+
b.declaration(chunk.kind, [
155+
b.declarator(declarator.id, b.call(b.await(b.call('$.save', declarator.init))))
156+
])
157+
);
158+
} else {
159+
const pattern = b.array_pattern(chunk.declarators.map(({ id }) => id));
160+
const init = b.call('$.all', ...chunk.declarators.map(({ init }) => init));
161+
body.splice(
162+
chunk.position + offset,
163+
0,
164+
b.declaration(chunk.kind, [b.declarator(pattern, b.await(init))])
165+
);
166+
}
167+
offset++;
165168
}
166-
offset++;
167169
}
168170
return {
169171
...node,

0 commit comments

Comments
 (0)