@@ -358,7 +358,11 @@ export function client_component(analysis, options) {
358358 const push_args = [ b . id ( '$$props' ) , b . literal ( analysis . runes ) ] ;
359359 if ( dev ) push_args . push ( b . id ( analysis . name ) ) ;
360360
361- let component_block = b . block ( [ ...legacy_reactive_declarations , ...group_binding_declarations ] ) ;
361+ let component_block = b . block ( [
362+ store_init ,
363+ ...legacy_reactive_declarations ,
364+ ...group_binding_declarations
365+ ] ) ;
362366
363367 const should_inject_context =
364368 dev ||
@@ -371,7 +375,6 @@ export function client_component(analysis, options) {
371375 component_block . body . push ( b . var ( '$$exports' ) ) ;
372376 }
373377 const body = b . block ( [
374- store_init ,
375378 ...store_setup ,
376379 ...state . instance_level_snippets ,
377380 .../** @type {ESTree.Statement[] } */ ( instance . body ) ,
@@ -382,10 +385,6 @@ export function client_component(analysis, options) {
382385 .../** @type {ESTree.Statement[] } */ ( template . body )
383386 ] ) ;
384387
385- if ( needs_store_cleanup ) {
386- body . body . push ( b . stmt ( b . call ( '$$cleanup' ) ) ) ;
387- }
388-
389388 component_block . body . push ( b . stmt ( b . call ( `$.async_body` , b . arrow ( [ ] , body , true ) ) ) ) ;
390389 } else {
391390 component_block . body . push (
@@ -395,7 +394,7 @@ export function client_component(analysis, options) {
395394 if ( should_inject_context && component_returned_object . length > 0 ) {
396395 component_block . body . push ( b . var ( '$$exports' , b . object ( component_returned_object ) ) ) ;
397396 }
398- component_block . body . unshift ( store_init , ...store_setup ) ;
397+ component_block . body . unshift ( ...store_setup ) ;
399398
400399 if ( ! analysis . runes && analysis . needs_context ) {
401400 component_block . body . push ( b . stmt ( b . call ( '$.init' , analysis . immutable ? b . true : undefined ) ) ) ;
@@ -465,7 +464,7 @@ export function client_component(analysis, options) {
465464 component_block . body . push ( to_push ) ;
466465 }
467466
468- if ( needs_store_cleanup && ! analysis . instance . has_await ) {
467+ if ( needs_store_cleanup ) {
469468 component_block . body . push ( b . stmt ( b . call ( '$$cleanup' ) ) ) ;
470469 }
471470
0 commit comments