Files
Hendrik LiebauandGitHub c54b8a3a36 Assign proper function names to server actions (#71478)
This PR adjusts the server action transforms to assign proper function names for the generated server reference proxies.

- If the original function has a name, this name is used.
- If a function expression is assigned to a variable, the variable's name is used.
- If an anonymous function expression is assigned to a prop, the prop's name is used.

In addition, this PR simplifies the output for exported functions, avoiding unnecessary `registerServerReference` calls.

It also fixes the source mapping of default exported server actions.

**Before:**

<img width="890" alt="before" src="https://github.com/user-attachments/assets/a3d6a5f8-d48e-474d-8f03-b49306fb704f">

**After:**

<img width="890" alt="after" src="https://github.com/user-attachments/assets/8f332690-6c26-46f1-9eef-7680f47ea578">

Next up, we will do the same for `'use cache'` functions.
2024-10-19 00:53:21 +02:00

22 lines
454 B
TypeScript

'use server'
export const foo = async () => {
return 'exported exported arrow function expression'
}
export async function bar() {
return 'exported named function declaration'
}
export const baz = async function () {
return 'exported anonymous function expression'
}
export const qux = async function quux() {
return 'exported named function expression'
}
export default async () => {
return 'default exported arrow function expression'
}