Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix shorthand prop wrongly handled in the Server Actions compiler (#5…
…0937) This PR fixes the case of having a shorthand prop `{ id }` referenced from a non-top level closure in the Server Actions compiler. The main problem is that an `Ident` in `PropOrSpread` is not considered as an `Expr`. See corresponding issue report and test case for more details. fix #50445 fix NEXT-1254
- Loading branch information
Showing
3 changed files
with
52 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 9 additions & 3 deletions
12
packages/next-swc/crates/core/tests/fixture/server-actions/server/5/output.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,25 @@ | ||
/* __next_internal_action_entry_do_not_use__ $$ACTION_0 */ import __create_action_proxy__ from "private-next-rsc-action-proxy"; | ||
import deleteFromDb from 'db'; | ||
const v1 = 'v1'; | ||
export function Item({ id1 , id2 }) { | ||
export function Item({ id1 , id2 , id3 , id4 }) { | ||
const v2 = id2; | ||
async function deleteItem(...args) { | ||
return $$ACTION_0.apply(null, (deleteItem.$$bound || []).concat(args)); | ||
} | ||
__create_action_proxy__("6d53ce510b2e36499b8f56038817b9bad86cabb4", [ | ||
id1, | ||
v2 | ||
v2, | ||
id3, | ||
id4.x | ||
], deleteItem, $$ACTION_0); | ||
return <Button action={deleteItem}>Delete</Button>; | ||
} | ||
export async function $$ACTION_0($$ACTION_ARG_0, $$ACTION_ARG_1) { | ||
export async function $$ACTION_0($$ACTION_ARG_0, $$ACTION_ARG_1, $$ACTION_ARG_2, $$ACTION_ARG_3) { | ||
await deleteFromDb($$ACTION_ARG_0); | ||
await deleteFromDb(v1); | ||
await deleteFromDb($$ACTION_ARG_1); | ||
await deleteFromDb({ | ||
id3: $$ACTION_ARG_2 | ||
}); | ||
await deleteFromDb($$ACTION_ARG_3); | ||
} |