Fix renamed export of Server Actions (#54241)
This fixes the compilation of `export { action as renamed }` syntax. Previously it's compiled as `export var action = ...` and with this fix, it will be `export var renamed = ...`. Closes #54229.
This commit is contained in:
parent
2bb12fc6bb
commit
0e78798f37
5 changed files with 25 additions and 2 deletions
|
@ -948,7 +948,9 @@ impl<C: Comments> VisitMut for ServerActions<C> {
|
||||||
declare: false,
|
declare: false,
|
||||||
decls: vec![VarDeclarator {
|
decls: vec![VarDeclarator {
|
||||||
span: DUMMY_SP,
|
span: DUMMY_SP,
|
||||||
name: Pat::Ident(ident.into()),
|
name: Pat::Ident(
|
||||||
|
Ident::new(export_name.clone().into(), DUMMY_SP).into(),
|
||||||
|
),
|
||||||
init: Some(Box::new(Expr::Call(CallExpr {
|
init: Some(Box::new(Expr::Call(CallExpr {
|
||||||
span: DUMMY_SP,
|
span: DUMMY_SP,
|
||||||
callee: Callee::Expr(Box::new(Expr::Ident(
|
callee: Callee::Expr(Box::new(Expr::Ident(
|
||||||
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
'use server'
|
||||||
|
|
||||||
|
async function foo() {}
|
||||||
|
export { foo as bar }
|
|
@ -0,0 +1,3 @@
|
||||||
|
/* __next_internal_action_entry_do_not_use__ bar */ import { createActionProxy } from "private-next-rsc-action-proxy";
|
||||||
|
import createServerReference from "private-next-rsc-action-client-wrapper";
|
||||||
|
export var bar = createServerReference("ac840dcaf5e8197cb02b7f3a43c119b7a770b272");
|
|
@ -26,3 +26,8 @@ export default async function (value) {
|
||||||
export async function redirectAction(path) {
|
export async function redirectAction(path) {
|
||||||
redirect(path)
|
redirect(path)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const original = async () => {
|
||||||
|
console.log('action')
|
||||||
|
}
|
||||||
|
export { original as renamed }
|
||||||
|
|
|
@ -2,7 +2,13 @@
|
||||||
|
|
||||||
import { useState } from 'react'
|
import { useState } from 'react'
|
||||||
|
|
||||||
import double, { inc, dec, redirectAction, getHeaders } from './actions'
|
import double, {
|
||||||
|
inc,
|
||||||
|
dec,
|
||||||
|
redirectAction,
|
||||||
|
getHeaders,
|
||||||
|
renamed,
|
||||||
|
} from './actions'
|
||||||
import { test } from './actions-lib'
|
import { test } from './actions-lib'
|
||||||
|
|
||||||
export default function Counter() {
|
export default function Counter() {
|
||||||
|
@ -16,6 +22,9 @@ export default function Counter() {
|
||||||
console.log(inc)
|
console.log(inc)
|
||||||
const newCount = await inc(count)
|
const newCount = await inc(count)
|
||||||
setCount(newCount)
|
setCount(newCount)
|
||||||
|
|
||||||
|
// test renamed action
|
||||||
|
renamed()
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
+1
|
+1
|
||||||
|
|
Loading…
Reference in a new issue