Skip to content

Commit 14a4f6c

Browse files
committed
fix
1 parent fa21f83 commit 14a4f6c

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

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

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -375,10 +375,13 @@ export function client_component(analysis, options) {
375375

376376
component_block.body.push(b.stmt(b.call(`$.async_body`, b.arrow([], body, true))));
377377
} else {
378-
component_block.body.push(
379-
.../** @type {ESTree.Statement[]} */ (instance.body),
380-
.../** @type {ESTree.Statement[]} */ (template.body)
381-
);
378+
component_block.body.push(.../** @type {ESTree.Statement[]} */ (instance.body));
379+
380+
if (!analysis.runes && analysis.needs_context) {
381+
component_block.body.push(b.stmt(b.call('$.init', analysis.immutable ? b.true : undefined)));
382+
}
383+
384+
component_block.body.push(.../** @type {ESTree.Statement[]} */ (template.body));
382385
}
383386

384387
if (analysis.needs_mutation_validation) {
@@ -387,10 +390,6 @@ export function client_component(analysis, options) {
387390
);
388391
}
389392

390-
if (!analysis.runes && analysis.needs_context) {
391-
component_block.body.push(b.stmt(b.call('$.init', analysis.immutable ? b.true : undefined)));
392-
}
393-
394393
const should_inject_context =
395394
dev ||
396395
analysis.needs_context ||

0 commit comments

Comments
 (0)