Unverified Commit 26a17fac authored by Shu Ding's avatar Shu Ding Committed by GitHub

Adjust transpiler to support inlined server functions with annotations (#47186)

This PR makes sure that we are not appending statements after the function or arrow expression, if they're actions. Instead we put all them in a `ParenExpr` so the entire thing can be defined inline.
fix NEXT-813 ([link](https://linear.app/vercel/issue/NEXT-813))
parent f36a6d89
/* __next_internal_action_entry_do_not_use__ $$ACTION_1 */ const foo = $$ACTION_0 = ()=>$$ACTION_1($$ACTION_0.$$bound);
$$ACTION_0.$$typeof = Symbol.for("react.server.reference");
$$ACTION_0.$$id = "188d5d945750dc32e2c842b93c75a65763d4a922";
$$ACTION_0.$$bound = [];
/* __next_internal_action_entry_do_not_use__ $$ACTION_1 */ const foo = ($$ACTION_0 = ()=>$$ACTION_1($$ACTION_0.$$bound), $$ACTION_0.$$typeof = Symbol.for("react.server.reference"), $$ACTION_0.$$id = "188d5d945750dc32e2c842b93c75a65763d4a922", $$ACTION_0.$$bound = [], $$ACTION_0);
export const $$ACTION_1 = (closure)=>{};
var $$ACTION_0;
/* __next_internal_action_entry_do_not_use__ $$ACTION_1 */ const foo = $$ACTION_0 = async ()=>$$ACTION_1($$ACTION_0.$$bound);
$$ACTION_0.$$typeof = Symbol.for("react.server.reference");
$$ACTION_0.$$id = "188d5d945750dc32e2c842b93c75a65763d4a922";
$$ACTION_0.$$bound = [];
/* __next_internal_action_entry_do_not_use__ $$ACTION_1 */ const foo = ($$ACTION_0 = async ()=>$$ACTION_1($$ACTION_0.$$bound), $$ACTION_0.$$typeof = Symbol.for("react.server.reference"), $$ACTION_0.$$id = "188d5d945750dc32e2c842b93c75a65763d4a922", $$ACTION_0.$$bound = [], $$ACTION_0);
export const $$ACTION_1 = async (closure)=>{
'use strict';
};
......
......@@ -2,13 +2,10 @@
const v1 = 'v1';
export function Item({ id1 , id2 }) {
const v2 = id2;
const deleteItem = $$ACTION_0 = async ()=>$$ACTION_1($$ACTION_0.$$bound);
$$ACTION_0.$$typeof = Symbol.for("react.server.reference");
$$ACTION_0.$$id = "188d5d945750dc32e2c842b93c75a65763d4a922";
$$ACTION_0.$$bound = [
const deleteItem = ($$ACTION_0 = async ()=>$$ACTION_1($$ACTION_0.$$bound), $$ACTION_0.$$typeof = Symbol.for("react.server.reference"), $$ACTION_0.$$id = "188d5d945750dc32e2c842b93c75a65763d4a922", $$ACTION_0.$$bound = [
id1,
v2
];
], $$ACTION_0);
return <Button action={deleteItem}>Delete</Button>;
}
export const $$ACTION_1 = async (closure)=>{
......@@ -16,4 +13,4 @@ export const $$ACTION_1 = async (closure)=>{
await deleteFromDb(v1);
await deleteFromDb(closure[1]);
};
var $$ACTION_0;
\ No newline at end of file
var $$ACTION_0;
......@@ -5,25 +5,19 @@ export function Item({ id1 , id2 }) {
// TODO: Fix the inline function cases.
return <>
<Button action={$$ACTION_0 = async ()=>$$ACTION_1($$ACTION_0.$$bound)}>Delete</Button>
<Button action={async function $$ACTION_2() {
return $$ACTION_3($$ACTION_2.$$bound);
}}>Delete</Button>
</>;
$$ACTION_0.$$typeof = Symbol.for("react.server.reference");
$$ACTION_0.$$id = "188d5d945750dc32e2c842b93c75a65763d4a922";
$$ACTION_0.$$bound = [
<Button action={$$ACTION_0 = async ()=>$$ACTION_1($$ACTION_0.$$bound), $$ACTION_0.$$typeof = Symbol.for("react.server.reference"), $$ACTION_0.$$id = "188d5d945750dc32e2c842b93c75a65763d4a922", $$ACTION_0.$$bound = [
id1,
v2
];
$$ACTION_2.$$typeof = Symbol.for("react.server.reference");
$$ACTION_2.$$id = "56a859f462d35a297c46a1bbd1e6a9058c104ab8";
$$ACTION_2.$$bound = [
], $$ACTION_0}>Delete</Button>
<Button action={$$ACTION_2 = async function() {
return $$ACTION_3($$ACTION_2.$$bound);
}, $$ACTION_2.$$typeof = Symbol.for("react.server.reference"), $$ACTION_2.$$id = "56a859f462d35a297c46a1bbd1e6a9058c104ab8", $$ACTION_2.$$bound = [
id1,
v2
];
], $$ACTION_2}>Delete</Button>
</>;
}
export const $$ACTION_1 = async (closure)=>{
await deleteFromDb(closure[0]);
......@@ -36,3 +30,4 @@ export async function $$ACTION_3(closure) {
await deleteFromDb(v1);
await deleteFromDb(closure[1]);
}
var $$ACTION_2;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment