@ -360,15 +360,27 @@ export function client_component(analysis, options) {
let component _block = b . block ( [
let component _block = b . block ( [
store _init ,
store _init ,
... store _setup ,
... legacy _reactive _declarations ,
... legacy _reactive _declarations ,
... group _binding _declarations
... group _binding _declarations
] ) ;
] ) ;
const should _inject _context =
dev ||
analysis . needs _context ||
analysis . reactive _statements . size > 0 ||
component _returned _object . length > 0 ;
if ( analysis . instance . has _await ) {
if ( analysis . instance . has _await ) {
if ( should _inject _context && component _returned _object . length > 0 ) {
component _block . body . push ( b . var ( '$$exports' ) ) ;
}
const body = b . block ( [
const body = b . block ( [
... store _setup ,
... state . instance _level _snippets ,
... state . instance _level _snippets ,
... /** @type {ESTree.Statement[]} */ ( instance . body ) ,
... /** @type {ESTree.Statement[]} */ ( instance . body ) ,
... ( should _inject _context && component _returned _object . length > 0
? [ b . stmt ( b . assignment ( '=' , b . id ( '$$exports' ) , b . object ( component _returned _object ) ) ) ]
: [ ] ) ,
b . if ( b . call ( '$.aborted' ) , b . return ( ) ) ,
b . if ( b . call ( '$.aborted' ) , b . return ( ) ) ,
... /** @type {ESTree.Statement[]} */ ( template . body )
... /** @type {ESTree.Statement[]} */ ( template . body )
] ) ;
] ) ;
@ -379,6 +391,10 @@ export function client_component(analysis, options) {
... state . instance _level _snippets ,
... state . instance _level _snippets ,
... /** @type {ESTree.Statement[]} */ ( instance . body )
... /** @type {ESTree.Statement[]} */ ( instance . body )
) ;
) ;
if ( should _inject _context && component _returned _object . length > 0 ) {
component _block . body . push ( b . var ( '$$exports' , b . object ( component _returned _object ) ) ) ;
}
component _block . body . unshift ( ... store _setup ) ;
if ( ! analysis . runes && analysis . needs _context ) {
if ( ! analysis . runes && analysis . needs _context ) {
component _block . body . push ( b . stmt ( b . call ( '$.init' , analysis . immutable ? b . true : undefined ) ) ) ;
component _block . body . push ( b . stmt ( b . call ( '$.init' , analysis . immutable ? b . true : undefined ) ) ) ;
@ -393,12 +409,6 @@ export function client_component(analysis, options) {
) ;
) ;
}
}
const should _inject _context =
dev ||
analysis . needs _context ||
analysis . reactive _statements . size > 0 ||
component _returned _object . length > 0 ;
let should _inject _props =
let should _inject _props =
should _inject _context ||
should _inject _context ||
analysis . needs _props ||
analysis . needs _props ||
@ -445,7 +455,7 @@ export function client_component(analysis, options) {
let to _push ;
let to _push ;
if ( component _returned _object . length > 0 ) {
if ( component _returned _object . length > 0 ) {
let pop _call = b . call ( '$.pop' , b . object( component _returned _object ) ) ;
let pop _call = b . call ( '$.pop' , b . id( '$$exports' ) ) ;
to _push = needs _store _cleanup ? b . var ( '$$pop' , pop _call ) : b . return ( pop _call ) ;
to _push = needs _store _cleanup ? b . var ( '$$pop' , pop _call ) : b . return ( pop _call ) ;
} else {
} else {
to _push = b . stmt ( b . call ( '$.pop' ) ) ;
to _push = b . stmt ( b . call ( '$.pop' ) ) ;
@ -456,6 +466,7 @@ export function client_component(analysis, options) {
if ( needs _store _cleanup ) {
if ( needs _store _cleanup ) {
component _block . body . push ( b . stmt ( b . call ( '$$cleanup' ) ) ) ;
component _block . body . push ( b . stmt ( b . call ( '$$cleanup' ) ) ) ;
if ( component _returned _object . length > 0 ) {
if ( component _returned _object . length > 0 ) {
component _block . body . push ( b . return ( b . id ( '$$pop' ) ) ) ;
component _block . body . push ( b . return ( b . id ( '$$pop' ) ) ) ;
}
}