|
|
|
@ -360,12 +360,24 @@ export function client_component(analysis, options) {
|
|
|
|
|
|
|
|
|
|
let component_block = b.block([...legacy_reactive_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 (should_inject_context && component_returned_object.length > 0) {
|
|
|
|
|
component_block.body.push(b.var('$$exports'));
|
|
|
|
|
}
|
|
|
|
|
const body = b.block([
|
|
|
|
|
store_init,
|
|
|
|
|
...store_setup,
|
|
|
|
|
...state.instance_level_snippets,
|
|
|
|
|
.../** @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()),
|
|
|
|
|
.../** @type {ESTree.Statement[]} */ (template.body)
|
|
|
|
|
]);
|
|
|
|
@ -380,6 +392,9 @@ export function client_component(analysis, options) {
|
|
|
|
|
...state.instance_level_snippets,
|
|
|
|
|
.../** @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_init, ...store_setup);
|
|
|
|
|
|
|
|
|
|
if (!analysis.runes && analysis.needs_context) {
|
|
|
|
@ -395,12 +410,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 =
|
|
|
|
|
should_inject_context ||
|
|
|
|
|
analysis.needs_props ||
|
|
|
|
@ -447,7 +456,7 @@ export function client_component(analysis, options) {
|
|
|
|
|
let to_push;
|
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
} else {
|
|
|
|
|
to_push = b.stmt(b.call('$.pop'));
|
|
|
|
|