chore: fix more wacky compiler output (#16794)

* chore: fix more wacky compiler output

* update tests
pull/16796/head
Rich Harris 2 days ago committed by GitHub
parent 4616422832
commit dc7da40369
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -198,11 +198,11 @@ export function server_component(analysis, options) {
b.unary('!', b.id('$$settled')), b.unary('!', b.id('$$settled')),
b.block([ b.block([
b.stmt(b.assignment('=', b.id('$$settled'), b.true)), b.stmt(b.assignment('=', b.id('$$settled'), b.true)),
b.stmt(b.assignment('=', b.id('$$inner_renderer'), b.call(' $$renderer.copy'))), b.stmt(b.assignment('=', b.id('$$inner_renderer'), b.call('$$renderer.copy'))),
b.stmt(b.call('$$render_inner', b.id('$$inner_renderer'))) b.stmt(b.call('$$render_inner', b.id('$$inner_renderer')))
]) ])
), ),
b.stmt(b.call(' $$renderer.subsume', b.id('$$inner_renderer'))) b.stmt(b.call('$$renderer.subsume', b.id('$$inner_renderer')))
]; ];
} }
@ -301,7 +301,7 @@ export function server_component(analysis, options) {
const code = b.literal(render_stylesheet(analysis.source, analysis, options).code); const code = b.literal(render_stylesheet(analysis.source, analysis, options).code);
body.push(b.const('$$css', b.object([b.init('hash', hash), b.init('code', code)]))); body.push(b.const('$$css', b.object([b.init('hash', hash), b.init('code', code)])));
component_block.body.unshift(b.stmt(b.call(' $$renderer.global.css.add', b.id('$$css')))); component_block.body.unshift(b.stmt(b.call('$$renderer.global.css.add', b.id('$$css'))));
} }
let should_inject_props = let should_inject_props =

@ -45,11 +45,11 @@ export function EachBlock(node, context) {
); );
if (node.fallback) { if (node.fallback) {
const open = b.stmt(b.call(b.id(' $$renderer.push'), block_open)); const open = b.stmt(b.call(b.id('$$renderer.push'), block_open));
const fallback = /** @type {BlockStatement} */ (context.visit(node.fallback)); const fallback = /** @type {BlockStatement} */ (context.visit(node.fallback));
fallback.body.unshift(b.stmt(b.call(b.id(' $$renderer.push'), block_open_else))); fallback.body.unshift(b.stmt(b.call(b.id('$$renderer.push'), block_open_else)));
block.body.push( block.body.push(
b.if( b.if(

@ -16,9 +16,9 @@ export function IfBlock(node, context) {
? /** @type {BlockStatement} */ (context.visit(node.alternate)) ? /** @type {BlockStatement} */ (context.visit(node.alternate))
: b.block([]); : b.block([]);
consequent.body.unshift(b.stmt(b.call(b.id(' $$renderer.push'), block_open))); consequent.body.unshift(b.stmt(b.call(b.id('$$renderer.push'), block_open)));
alternate.body.unshift(b.stmt(b.call(b.id(' $$renderer.push'), block_open_else))); alternate.body.unshift(b.stmt(b.call(b.id('$$renderer.push'), block_open_else)));
/** @type {Statement} */ /** @type {Statement} */
let statement = b.if(test, consequent, alternate); let statement = b.if(test, consequent, alternate);

@ -97,7 +97,7 @@ export function RegularElement(node, context) {
b.stmt( b.stmt(
b.assignment( b.assignment(
'=', '=',
b.id(' $$renderer.local.select_value'), b.id('$$renderer.local.select_value'),
b.member( b.member(
build_spread_object( build_spread_object(
node, node,
@ -125,7 +125,7 @@ export function RegularElement(node, context) {
); );
} }
const left = b.id(' $$renderer.local.select_value'); const left = b.id('$$renderer.local.select_value');
if (value.type === 'Attribute') { if (value.type === 'Attribute') {
state.template.push( state.template.push(
b.stmt(b.assignment('=', left, build_attribute_value(value.value, context))) b.stmt(b.assignment('=', left, build_attribute_value(value.value, context)))

@ -80,7 +80,7 @@ export function process_children(nodes, { visit, state }) {
flush(); flush();
const visited = /** @type {Expression} */ (visit(node.expression)); const visited = /** @type {Expression} */ (visit(node.expression));
state.template.push( state.template.push(
b.stmt(b.call(' $$renderer.push', b.thunk(b.call('$.escape', visited), true))) b.stmt(b.call('$$renderer.push', b.thunk(b.call('$.escape', visited), true)))
); );
} else if (node.type === 'Text' || node.type === 'Comment' || node.type === 'ExpressionTag') { } else if (node.type === 'Text' || node.type === 'Comment' || node.type === 'ExpressionTag') {
sequence.push(node); sequence.push(node);
@ -119,7 +119,7 @@ export function build_template(template) {
statements.push( statements.push(
b.stmt( b.stmt(
b.call( b.call(
b.id(' $$renderer.push'), b.id('$$renderer.push'),
b.template( b.template(
strings.map((cooked, i) => b.quasi(cooked, i === strings.length - 1)), strings.map((cooked, i) => b.quasi(cooked, i === strings.length - 1)),
expressions expressions
@ -267,7 +267,7 @@ export function build_getter(node, state) {
* @returns {Statement} * @returns {Statement}
*/ */
export function call_child_renderer(body, async) { export function call_child_renderer(body, async) {
return b.stmt(b.call(' $$renderer.child', b.arrow([b.id('$$renderer')], body, async))); return b.stmt(b.call('$$renderer.child', b.arrow([b.id('$$renderer')], body, async)));
} }
/** /**
@ -277,7 +277,7 @@ export function call_child_renderer(body, async) {
*/ */
export function call_component_renderer(body, component_fn_id) { export function call_component_renderer(body, component_fn_id) {
return b.stmt( return b.stmt(
b.call(' $$renderer.component', b.arrow([b.id('$$renderer')], body, false), component_fn_id) b.call('$$renderer.component', b.arrow([b.id('$$renderer')], body, false), component_fn_id)
); );
} }

Loading…
Cancel
Save