From cd95fe408500c647cd0a4aebb06091937f1a6122 Mon Sep 17 00:00:00 2001 From: Shu Ding Date: Tue, 15 Aug 2023 01:16:28 +0200 Subject: [PATCH] Adjust internal action proxy export (#54004) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This PR changes the internal `createActionProxy` util from a default export to a named export, as the default export could be problematic if it's built without the "esModuleInterop" step. --------- Co-authored-by: Balázs Orbán --- packages/next-swc/crates/core/src/server_actions.rs | 12 +++++++----- .../errors/server-actions/client-graph/1/output.js | 4 ++-- .../errors/server-actions/server-graph/1/output.js | 4 ++-- .../errors/server-actions/server-graph/2/output.js | 4 ++-- .../errors/server-actions/server-graph/3/output.js | 4 ++-- .../errors/server-actions/server-graph/4/output.js | 2 +- .../errors/server-actions/server-graph/5/output.js | 2 +- .../errors/server-actions/server-graph/6/output.js | 2 +- .../errors/server-actions/server-graph/7/output.js | 4 ++-- .../errors/server-actions/server-graph/8/output.js | 4 ++-- .../tests/fixture/server-actions/client/1/output.js | 2 +- .../tests/fixture/server-actions/client/2/output.js | 2 +- .../tests/fixture/server-actions/client/3/output.js | 2 +- .../tests/fixture/server-actions/server/1/output.js | 6 +++--- .../tests/fixture/server-actions/server/10/output.js | 4 ++-- .../tests/fixture/server-actions/server/11/output.js | 4 ++-- .../tests/fixture/server-actions/server/12/output.js | 4 ++-- .../tests/fixture/server-actions/server/13/output.js | 6 +++--- .../tests/fixture/server-actions/server/14/output.js | 4 ++-- .../tests/fixture/server-actions/server/15/output.js | 4 ++-- .../tests/fixture/server-actions/server/16/output.js | 8 ++++---- .../tests/fixture/server-actions/server/17/output.js | 6 +++--- .../tests/fixture/server-actions/server/18/output.js | 6 +++--- .../tests/fixture/server-actions/server/19/output.js | 4 ++-- .../tests/fixture/server-actions/server/2/output.js | 6 +++--- .../tests/fixture/server-actions/server/20/output.js | 4 ++-- .../tests/fixture/server-actions/server/21/output.js | 8 ++++---- .../tests/fixture/server-actions/server/22/output.js | 6 +++--- .../tests/fixture/server-actions/server/23/output.js | 6 +++--- .../tests/fixture/server-actions/server/3/output.js | 4 ++-- .../tests/fixture/server-actions/server/4/output.js | 8 ++++---- .../tests/fixture/server-actions/server/5/output.js | 4 ++-- .../tests/fixture/server-actions/server/6/output.js | 4 ++-- .../tests/fixture/server-actions/server/7/output.js | 4 ++-- .../tests/fixture/server-actions/server/8/output.js | 4 ++-- .../tests/fixture/server-actions/server/9/output.js | 8 ++++---- .../loaders/next-flight-loader/action-proxy.ts | 2 +- 37 files changed, 87 insertions(+), 85 deletions(-) diff --git a/packages/next-swc/crates/core/src/server_actions.rs b/packages/next-swc/crates/core/src/server_actions.rs index 4802d03365f9..5c7254a598c1 100644 --- a/packages/next-swc/crates/core/src/server_actions.rs +++ b/packages/next-swc/crates/core/src/server_actions.rs @@ -1053,13 +1053,15 @@ impl VisitMut for ServerActions { }, ); - // import __createActionProxy__ from 'private-next-rsc-action-proxy' + // import { createActionProxy } from 'private-next-rsc-action-proxy' // createServerReference("action_id") new.push(ModuleItem::ModuleDecl(ModuleDecl::Import(ImportDecl { span: DUMMY_SP, - specifiers: vec![ImportSpecifier::Default(ImportDefaultSpecifier { + specifiers: vec![ImportSpecifier::Named(ImportNamedSpecifier { span: DUMMY_SP, - local: quote_ident!("__create_action_proxy__"), + local: quote_ident!("createActionProxy"), + imported: None, + is_type_only: false, })], src: Box::new(Str { span: DUMMY_SP, @@ -1173,7 +1175,7 @@ fn annotate_ident_as_action( export_name: String, maybe_orig_action_ident: Option, ) { - // Add the proxy wrapper call `__create_action_proxy__($$id, $$bound, myAction, + // Add the proxy wrapper call `createActionProxy($$id, $$bound, myAction, // maybe_orig_action)`. let mut args = vec![ // $$id @@ -1205,7 +1207,7 @@ fn annotate_ident_as_action( span: DUMMY_SP, expr: Box::new(Expr::Call(CallExpr { span: DUMMY_SP, - callee: quote_ident!("__create_action_proxy__").as_callee(), + callee: quote_ident!("createActionProxy").as_callee(), args: if let Some(orig_action_ident) = maybe_orig_action_ident { args.push(ExprOrSpread { spread: None, diff --git a/packages/next-swc/crates/core/tests/errors/server-actions/client-graph/1/output.js b/packages/next-swc/crates/core/tests/errors/server-actions/client-graph/1/output.js index d6424694df7d..3275be74a29a 100644 --- a/packages/next-swc/crates/core/tests/errors/server-actions/client-graph/1/output.js +++ b/packages/next-swc/crates/core/tests/errors/server-actions/client-graph/1/output.js @@ -1,9 +1,9 @@ -/* __next_internal_client_entry_do_not_use__ default auto */ /* __next_internal_action_entry_do_not_use__ $$ACTION_0 */ import __create_action_proxy__ from "private-next-rsc-action-proxy"; +/* __next_internal_client_entry_do_not_use__ default auto */ /* __next_internal_action_entry_do_not_use__ $$ACTION_0 */ import { createActionProxy } from "private-next-rsc-action-proxy"; export default function App() { async function fn(...args) { return $$ACTION_0.apply(null, (fn.$$bound || []).concat(args)); } - __create_action_proxy__("6d53ce510b2e36499b8f56038817b9bad86cabb4", null, fn, $$ACTION_0); + createActionProxy("6d53ce510b2e36499b8f56038817b9bad86cabb4", null, fn, $$ACTION_0); return
App
; } export async function $$ACTION_0() {} diff --git a/packages/next-swc/crates/core/tests/errors/server-actions/server-graph/1/output.js b/packages/next-swc/crates/core/tests/errors/server-actions/server-graph/1/output.js index 326cdd873154..067c19bd7f50 100644 --- a/packages/next-swc/crates/core/tests/errors/server-actions/server-graph/1/output.js +++ b/packages/next-swc/crates/core/tests/errors/server-actions/server-graph/1/output.js @@ -1,7 +1,7 @@ -/* __next_internal_action_entry_do_not_use__ foo */ import __create_action_proxy__ from "private-next-rsc-action-proxy"; +/* __next_internal_action_entry_do_not_use__ foo */ import { createActionProxy } from "private-next-rsc-action-proxy"; export function foo() {} import ensureServerEntryExports from "private-next-rsc-action-validate"; ensureServerEntryExports([ foo ]); -__create_action_proxy__("ab21efdafbe611287bc25c0462b1e0510d13e48b", null, foo); +createActionProxy("ab21efdafbe611287bc25c0462b1e0510d13e48b", null, foo); diff --git a/packages/next-swc/crates/core/tests/errors/server-actions/server-graph/2/output.js b/packages/next-swc/crates/core/tests/errors/server-actions/server-graph/2/output.js index a353534d8400..9eba656fb0ed 100644 --- a/packages/next-swc/crates/core/tests/errors/server-actions/server-graph/2/output.js +++ b/packages/next-swc/crates/core/tests/errors/server-actions/server-graph/2/output.js @@ -1,8 +1,8 @@ -/* __next_internal_action_entry_do_not_use__ bar */ import __create_action_proxy__ from "private-next-rsc-action-proxy"; +/* __next_internal_action_entry_do_not_use__ bar */ import { createActionProxy } from "private-next-rsc-action-proxy"; 'use strict'; export function bar() {} import ensureServerEntryExports from "private-next-rsc-action-validate"; ensureServerEntryExports([ bar ]); -__create_action_proxy__("ac840dcaf5e8197cb02b7f3a43c119b7a770b272", null, bar); +createActionProxy("ac840dcaf5e8197cb02b7f3a43c119b7a770b272", null, bar); diff --git a/packages/next-swc/crates/core/tests/errors/server-actions/server-graph/3/output.js b/packages/next-swc/crates/core/tests/errors/server-actions/server-graph/3/output.js index f0c72c9e6cbd..5b742ce28a9d 100644 --- a/packages/next-swc/crates/core/tests/errors/server-actions/server-graph/3/output.js +++ b/packages/next-swc/crates/core/tests/errors/server-actions/server-graph/3/output.js @@ -1,7 +1,7 @@ -/* __next_internal_action_entry_do_not_use__ x */ import __create_action_proxy__ from "private-next-rsc-action-proxy"; +/* __next_internal_action_entry_do_not_use__ x */ import { createActionProxy } from "private-next-rsc-action-proxy"; export const x = 1; import ensureServerEntryExports from "private-next-rsc-action-validate"; ensureServerEntryExports([ x ]); -__create_action_proxy__("b78c261f135a7a852508c2920bd7228020ff4bd7", null, x); +createActionProxy("b78c261f135a7a852508c2920bd7228020ff4bd7", null, x); diff --git a/packages/next-swc/crates/core/tests/errors/server-actions/server-graph/4/output.js b/packages/next-swc/crates/core/tests/errors/server-actions/server-graph/4/output.js index 6a2fce67c8a8..799cfbc141b1 100644 --- a/packages/next-swc/crates/core/tests/errors/server-actions/server-graph/4/output.js +++ b/packages/next-swc/crates/core/tests/errors/server-actions/server-graph/4/output.js @@ -1,4 +1,4 @@ -/* __next_internal_action_entry_do_not_use__ */ import __create_action_proxy__ from "private-next-rsc-action-proxy"; +/* __next_internal_action_entry_do_not_use__ */ import { createActionProxy } from "private-next-rsc-action-proxy"; export default class Component { render() { return null; diff --git a/packages/next-swc/crates/core/tests/errors/server-actions/server-graph/5/output.js b/packages/next-swc/crates/core/tests/errors/server-actions/server-graph/5/output.js index 224a87066d77..288bb0a3256c 100644 --- a/packages/next-swc/crates/core/tests/errors/server-actions/server-graph/5/output.js +++ b/packages/next-swc/crates/core/tests/errors/server-actions/server-graph/5/output.js @@ -1,4 +1,4 @@ -/* __next_internal_action_entry_do_not_use__ */ import __create_action_proxy__ from "private-next-rsc-action-proxy"; +/* __next_internal_action_entry_do_not_use__ */ import { createActionProxy } from "private-next-rsc-action-proxy"; export * from 'foo'; import ensureServerEntryExports from "private-next-rsc-action-validate"; ensureServerEntryExports([]); diff --git a/packages/next-swc/crates/core/tests/errors/server-actions/server-graph/6/output.js b/packages/next-swc/crates/core/tests/errors/server-actions/server-graph/6/output.js index 28034474e5b3..1dc0ea40d167 100644 --- a/packages/next-swc/crates/core/tests/errors/server-actions/server-graph/6/output.js +++ b/packages/next-swc/crates/core/tests/errors/server-actions/server-graph/6/output.js @@ -1,4 +1,4 @@ -/* __next_internal_action_entry_do_not_use__ */ import __create_action_proxy__ from "private-next-rsc-action-proxy"; +/* __next_internal_action_entry_do_not_use__ */ import { createActionProxy } from "private-next-rsc-action-proxy"; export default (()=>{}); import ensureServerEntryExports from "private-next-rsc-action-validate"; ensureServerEntryExports([]); diff --git a/packages/next-swc/crates/core/tests/errors/server-actions/server-graph/7/output.js b/packages/next-swc/crates/core/tests/errors/server-actions/server-graph/7/output.js index 43490b64aba2..672090e8bd46 100644 --- a/packages/next-swc/crates/core/tests/errors/server-actions/server-graph/7/output.js +++ b/packages/next-swc/crates/core/tests/errors/server-actions/server-graph/7/output.js @@ -1,4 +1,4 @@ -/* __next_internal_action_entry_do_not_use__ $$ACTION_1 */ import __create_action_proxy__ from "private-next-rsc-action-proxy"; -const foo = ($$ACTION_0 = async (...args)=>$$ACTION_1.apply(null, ($$ACTION_0.$$bound || []).concat(args)), __create_action_proxy__("188d5d945750dc32e2c842b93c75a65763d4a922", null, $$ACTION_0, $$ACTION_1), $$ACTION_0); +/* __next_internal_action_entry_do_not_use__ $$ACTION_1 */ import { createActionProxy } from "private-next-rsc-action-proxy"; +const foo = ($$ACTION_0 = async (...args)=>$$ACTION_1.apply(null, ($$ACTION_0.$$bound || []).concat(args)), createActionProxy("188d5d945750dc32e2c842b93c75a65763d4a922", null, $$ACTION_0, $$ACTION_1), $$ACTION_0); export var $$ACTION_1 = ()=>{}; var $$ACTION_0; diff --git a/packages/next-swc/crates/core/tests/errors/server-actions/server-graph/8/output.js b/packages/next-swc/crates/core/tests/errors/server-actions/server-graph/8/output.js index 1e524704cc8e..1a708ec936d8 100644 --- a/packages/next-swc/crates/core/tests/errors/server-actions/server-graph/8/output.js +++ b/packages/next-swc/crates/core/tests/errors/server-actions/server-graph/8/output.js @@ -1,5 +1,5 @@ -/* __next_internal_action_entry_do_not_use__ $$ACTION_1 */ import __create_action_proxy__ from "private-next-rsc-action-proxy"; -const foo = ($$ACTION_0 = async (...args)=>$$ACTION_1.apply(null, ($$ACTION_0.$$bound || []).concat(args)), __create_action_proxy__("188d5d945750dc32e2c842b93c75a65763d4a922", null, $$ACTION_0, $$ACTION_1), $$ACTION_0); +/* __next_internal_action_entry_do_not_use__ $$ACTION_1 */ import { createActionProxy } from "private-next-rsc-action-proxy"; +const foo = ($$ACTION_0 = async (...args)=>$$ACTION_1.apply(null, ($$ACTION_0.$$bound || []).concat(args)), createActionProxy("188d5d945750dc32e2c842b93c75a65763d4a922", null, $$ACTION_0, $$ACTION_1), $$ACTION_0); export var $$ACTION_1 = async ()=>{ 'use strict'; }; diff --git a/packages/next-swc/crates/core/tests/fixture/server-actions/client/1/output.js b/packages/next-swc/crates/core/tests/fixture/server-actions/client/1/output.js index 9474a51c9c41..5ff5df5f6e4e 100644 --- a/packages/next-swc/crates/core/tests/fixture/server-actions/client/1/output.js +++ b/packages/next-swc/crates/core/tests/fixture/server-actions/client/1/output.js @@ -1,5 +1,5 @@ // app/send.ts -/* __next_internal_action_entry_do_not_use__ myAction,default */ import __create_action_proxy__ from "private-next-rsc-action-proxy"; +/* __next_internal_action_entry_do_not_use__ myAction,default */ import { createActionProxy } from "private-next-rsc-action-proxy"; import createServerReference from "private-next-rsc-action-client-wrapper"; export var myAction = createServerReference("e10665baac148856374b2789aceb970f66fec33e"); export default createServerReference("c18c215a6b7cdc64bf709f3a714ffdef1bf9651d"); diff --git a/packages/next-swc/crates/core/tests/fixture/server-actions/client/2/output.js b/packages/next-swc/crates/core/tests/fixture/server-actions/client/2/output.js index 4ccc8d829116..a3ac7d25bef5 100644 --- a/packages/next-swc/crates/core/tests/fixture/server-actions/client/2/output.js +++ b/packages/next-swc/crates/core/tests/fixture/server-actions/client/2/output.js @@ -1,4 +1,4 @@ // app/send.ts -/* __next_internal_action_entry_do_not_use__ foo */ import __create_action_proxy__ from "private-next-rsc-action-proxy"; +/* __next_internal_action_entry_do_not_use__ foo */ import { createActionProxy } from "private-next-rsc-action-proxy"; import createServerReference from "private-next-rsc-action-client-wrapper"; export var foo = createServerReference("ab21efdafbe611287bc25c0462b1e0510d13e48b"); diff --git a/packages/next-swc/crates/core/tests/fixture/server-actions/client/3/output.js b/packages/next-swc/crates/core/tests/fixture/server-actions/client/3/output.js index 24f80d63cfb3..32b9d8367a4a 100644 --- a/packages/next-swc/crates/core/tests/fixture/server-actions/client/3/output.js +++ b/packages/next-swc/crates/core/tests/fixture/server-actions/client/3/output.js @@ -1,4 +1,4 @@ -/* __next_internal_action_entry_do_not_use__ sampleFunction,sampleFunction2,sampleFunction3,sampleFunction4 */ import __create_action_proxy__ from "private-next-rsc-action-proxy"; +/* __next_internal_action_entry_do_not_use__ sampleFunction,sampleFunction2,sampleFunction3,sampleFunction4 */ import { createActionProxy } from "private-next-rsc-action-proxy"; import createServerReference from "private-next-rsc-action-client-wrapper"; export var sampleFunction = createServerReference("bd336abe00c3c59da66acb696fc8e151d8e54ea4"); export var sampleFunction2 = createServerReference("a0c73dd6f5af839e3335c6b19262ecb86cca6af4"); diff --git a/packages/next-swc/crates/core/tests/fixture/server-actions/server/1/output.js b/packages/next-swc/crates/core/tests/fixture/server-actions/server/1/output.js index 34b9013cd3e7..678644bb9ca2 100644 --- a/packages/next-swc/crates/core/tests/fixture/server-actions/server/1/output.js +++ b/packages/next-swc/crates/core/tests/fixture/server-actions/server/1/output.js @@ -1,10 +1,10 @@ -/* __next_internal_action_entry_do_not_use__ $$ACTION_0,$$ACTION_2 */ import __create_action_proxy__ from "private-next-rsc-action-proxy"; +/* __next_internal_action_entry_do_not_use__ $$ACTION_0,$$ACTION_2 */ import { createActionProxy } from "private-next-rsc-action-proxy"; import deleteFromDb from 'db'; export function Item({ id1 , id2 }) { async function deleteItem(...args) { return $$ACTION_0.apply(null, (deleteItem.$$bound || []).concat(args)); } - __create_action_proxy__("6d53ce510b2e36499b8f56038817b9bad86cabb4", [ + createActionProxy("6d53ce510b2e36499b8f56038817b9bad86cabb4", [ id1, id2 ], deleteItem, $$ACTION_0); @@ -19,7 +19,7 @@ export default function Home() { name: 'John', test: 'test' }; - const action = ($$ACTION_1 = async (...args)=>$$ACTION_2.apply(null, ($$ACTION_1.$$bound || []).concat(args)), __create_action_proxy__("9878bfa39811ca7650992850a8751f9591b6a557", [ + const action = ($$ACTION_1 = async (...args)=>$$ACTION_2.apply(null, ($$ACTION_1.$$bound || []).concat(args)), createActionProxy("9878bfa39811ca7650992850a8751f9591b6a557", [ info.name, info.test ], $$ACTION_1, $$ACTION_2), $$ACTION_1); diff --git a/packages/next-swc/crates/core/tests/fixture/server-actions/server/10/output.js b/packages/next-swc/crates/core/tests/fixture/server-actions/server/10/output.js index f68893db07b4..ce66f1f15ea1 100644 --- a/packages/next-swc/crates/core/tests/fixture/server-actions/server/10/output.js +++ b/packages/next-swc/crates/core/tests/fixture/server-actions/server/10/output.js @@ -1,7 +1,7 @@ -/* __next_internal_action_entry_do_not_use__ default */ import __create_action_proxy__ from "private-next-rsc-action-proxy"; +/* __next_internal_action_entry_do_not_use__ default */ import { createActionProxy } from "private-next-rsc-action-proxy"; export default async function foo() {} import ensureServerEntryExports from "private-next-rsc-action-validate"; ensureServerEntryExports([ foo ]); -__create_action_proxy__("c18c215a6b7cdc64bf709f3a714ffdef1bf9651d", null, foo); +createActionProxy("c18c215a6b7cdc64bf709f3a714ffdef1bf9651d", null, foo); diff --git a/packages/next-swc/crates/core/tests/fixture/server-actions/server/11/output.js b/packages/next-swc/crates/core/tests/fixture/server-actions/server/11/output.js index cf9b2cf482cd..b0455322ae6d 100644 --- a/packages/next-swc/crates/core/tests/fixture/server-actions/server/11/output.js +++ b/packages/next-swc/crates/core/tests/fixture/server-actions/server/11/output.js @@ -1,7 +1,7 @@ -/* __next_internal_action_entry_do_not_use__ default */ import __create_action_proxy__ from "private-next-rsc-action-proxy"; +/* __next_internal_action_entry_do_not_use__ default */ import { createActionProxy } from "private-next-rsc-action-proxy"; export default async function $$ACTION_0() {} import ensureServerEntryExports from "private-next-rsc-action-validate"; ensureServerEntryExports([ $$ACTION_0 ]); -__create_action_proxy__("c18c215a6b7cdc64bf709f3a714ffdef1bf9651d", null, $$ACTION_0); +createActionProxy("c18c215a6b7cdc64bf709f3a714ffdef1bf9651d", null, $$ACTION_0); diff --git a/packages/next-swc/crates/core/tests/fixture/server-actions/server/12/output.js b/packages/next-swc/crates/core/tests/fixture/server-actions/server/12/output.js index a0f27b7aada0..a08633ca2042 100644 --- a/packages/next-swc/crates/core/tests/fixture/server-actions/server/12/output.js +++ b/packages/next-swc/crates/core/tests/fixture/server-actions/server/12/output.js @@ -1,8 +1,8 @@ -/* __next_internal_action_entry_do_not_use__ default */ import __create_action_proxy__ from "private-next-rsc-action-proxy"; +/* __next_internal_action_entry_do_not_use__ default */ import { createActionProxy } from "private-next-rsc-action-proxy"; async function foo() {} export default foo; import ensureServerEntryExports from "private-next-rsc-action-validate"; ensureServerEntryExports([ foo ]); -__create_action_proxy__("c18c215a6b7cdc64bf709f3a714ffdef1bf9651d", null, foo); +createActionProxy("c18c215a6b7cdc64bf709f3a714ffdef1bf9651d", null, foo); diff --git a/packages/next-swc/crates/core/tests/fixture/server-actions/server/13/output.js b/packages/next-swc/crates/core/tests/fixture/server-actions/server/13/output.js index acf083af50f9..02de3e7b1425 100644 --- a/packages/next-swc/crates/core/tests/fixture/server-actions/server/13/output.js +++ b/packages/next-swc/crates/core/tests/fixture/server-actions/server/13/output.js @@ -1,4 +1,4 @@ -/* __next_internal_action_entry_do_not_use__ default,bar */ import __create_action_proxy__ from "private-next-rsc-action-proxy"; +/* __next_internal_action_entry_do_not_use__ default,bar */ import { createActionProxy } from "private-next-rsc-action-proxy"; const foo = async function() {}; export default foo; const bar = async function() {}; @@ -8,5 +8,5 @@ ensureServerEntryExports([ foo, bar ]); -__create_action_proxy__("c18c215a6b7cdc64bf709f3a714ffdef1bf9651d", null, foo); -__create_action_proxy__("ac840dcaf5e8197cb02b7f3a43c119b7a770b272", null, bar); +createActionProxy("c18c215a6b7cdc64bf709f3a714ffdef1bf9651d", null, foo); +createActionProxy("ac840dcaf5e8197cb02b7f3a43c119b7a770b272", null, bar); diff --git a/packages/next-swc/crates/core/tests/fixture/server-actions/server/14/output.js b/packages/next-swc/crates/core/tests/fixture/server-actions/server/14/output.js index 1f95aa97ad84..dd1abeb00a18 100644 --- a/packages/next-swc/crates/core/tests/fixture/server-actions/server/14/output.js +++ b/packages/next-swc/crates/core/tests/fixture/server-actions/server/14/output.js @@ -1,4 +1,4 @@ -/* __next_internal_action_entry_do_not_use__ foo */ import __create_action_proxy__ from "private-next-rsc-action-proxy"; +/* __next_internal_action_entry_do_not_use__ foo */ import { createActionProxy } from "private-next-rsc-action-proxy"; export async function foo() { async function bar() {} } @@ -6,4 +6,4 @@ import ensureServerEntryExports from "private-next-rsc-action-validate"; ensureServerEntryExports([ foo ]); -__create_action_proxy__("ab21efdafbe611287bc25c0462b1e0510d13e48b", null, foo); +createActionProxy("ab21efdafbe611287bc25c0462b1e0510d13e48b", null, foo); diff --git a/packages/next-swc/crates/core/tests/fixture/server-actions/server/15/output.js b/packages/next-swc/crates/core/tests/fixture/server-actions/server/15/output.js index e93d4b6f0dab..fa74cf87bc23 100644 --- a/packages/next-swc/crates/core/tests/fixture/server-actions/server/15/output.js +++ b/packages/next-swc/crates/core/tests/fixture/server-actions/server/15/output.js @@ -1,4 +1,4 @@ -/* __next_internal_action_entry_do_not_use__ default */ import __create_action_proxy__ from "private-next-rsc-action-proxy"; +/* __next_internal_action_entry_do_not_use__ default */ import { createActionProxy } from "private-next-rsc-action-proxy"; export default $$ACTION_0 = async (a, b)=>{ console.log(a, b); }; @@ -7,4 +7,4 @@ import ensureServerEntryExports from "private-next-rsc-action-validate"; ensureServerEntryExports([ $$ACTION_0 ]); -__create_action_proxy__("c18c215a6b7cdc64bf709f3a714ffdef1bf9651d", null, $$ACTION_0); +createActionProxy("c18c215a6b7cdc64bf709f3a714ffdef1bf9651d", null, $$ACTION_0); diff --git a/packages/next-swc/crates/core/tests/fixture/server-actions/server/16/output.js b/packages/next-swc/crates/core/tests/fixture/server-actions/server/16/output.js index 145c5669e0f5..f4009458e73d 100644 --- a/packages/next-swc/crates/core/tests/fixture/server-actions/server/16/output.js +++ b/packages/next-swc/crates/core/tests/fixture/server-actions/server/16/output.js @@ -1,9 +1,9 @@ -/* __next_internal_action_entry_do_not_use__ $$ACTION_1,$$ACTION_2,$$ACTION_4 */ import __create_action_proxy__ from "private-next-rsc-action-proxy"; +/* __next_internal_action_entry_do_not_use__ $$ACTION_1,$$ACTION_2,$$ACTION_4 */ import { createActionProxy } from "private-next-rsc-action-proxy"; import deleteFromDb from 'db'; const v1 = 'v1'; export function Item({ id1 , id2 }) { const v2 = id2; - const deleteItem = ($$ACTION_0 = async (...args)=>$$ACTION_1.apply(null, ($$ACTION_0.$$bound || []).concat(args)), __create_action_proxy__("188d5d945750dc32e2c842b93c75a65763d4a922", [ + const deleteItem = ($$ACTION_0 = async (...args)=>$$ACTION_1.apply(null, ($$ACTION_0.$$bound || []).concat(args)), createActionProxy("188d5d945750dc32e2c842b93c75a65763d4a922", [ id1, v2 ], $$ACTION_0, $$ACTION_1), $$ACTION_0); @@ -19,7 +19,7 @@ const f = (x)=>{ async function g(...args) { return $$ACTION_2.apply(null, (g.$$bound || []).concat(args)); } - __create_action_proxy__("9878bfa39811ca7650992850a8751f9591b6a557", [ + createActionProxy("9878bfa39811ca7650992850a8751f9591b6a557", [ x ], g, $$ACTION_2); }; @@ -27,7 +27,7 @@ export async function $$ACTION_2($$ACTION_ARG_0, y, ...z) { return $$ACTION_ARG_0 + y + z[0]; } const g = (x)=>{ - f = ($$ACTION_3 = async (...args)=>$$ACTION_4.apply(null, ($$ACTION_3.$$bound || []).concat(args)), __create_action_proxy__("9c0dd1f7c2b3f41d32e10f5c437de3d67ad32c6c", [ + f = ($$ACTION_3 = async (...args)=>$$ACTION_4.apply(null, ($$ACTION_3.$$bound || []).concat(args)), createActionProxy("9c0dd1f7c2b3f41d32e10f5c437de3d67ad32c6c", [ x ], $$ACTION_3, $$ACTION_4), $$ACTION_3); }; diff --git a/packages/next-swc/crates/core/tests/fixture/server-actions/server/17/output.js b/packages/next-swc/crates/core/tests/fixture/server-actions/server/17/output.js index 4a48b3b53583..ae793593bd6c 100644 --- a/packages/next-swc/crates/core/tests/fixture/server-actions/server/17/output.js +++ b/packages/next-swc/crates/core/tests/fixture/server-actions/server/17/output.js @@ -1,4 +1,4 @@ -/* __next_internal_action_entry_do_not_use__ foo,bar */ import __create_action_proxy__ from "private-next-rsc-action-proxy"; +/* __next_internal_action_entry_do_not_use__ foo,bar */ import { createActionProxy } from "private-next-rsc-action-proxy"; export const foo = async ()=>{}; const bar = async ()=>{}; export { bar }; @@ -7,5 +7,5 @@ ensureServerEntryExports([ foo, bar ]); -__create_action_proxy__("ab21efdafbe611287bc25c0462b1e0510d13e48b", null, foo); -__create_action_proxy__("ac840dcaf5e8197cb02b7f3a43c119b7a770b272", null, bar); +createActionProxy("ab21efdafbe611287bc25c0462b1e0510d13e48b", null, foo); +createActionProxy("ac840dcaf5e8197cb02b7f3a43c119b7a770b272", null, bar); diff --git a/packages/next-swc/crates/core/tests/fixture/server-actions/server/18/output.js b/packages/next-swc/crates/core/tests/fixture/server-actions/server/18/output.js index 9fa45bdf32ab..8c4be7568f09 100644 --- a/packages/next-swc/crates/core/tests/fixture/server-actions/server/18/output.js +++ b/packages/next-swc/crates/core/tests/fixture/server-actions/server/18/output.js @@ -1,11 +1,11 @@ -/* __next_internal_action_entry_do_not_use__ $$ACTION_1,$$ACTION_3 */ import __create_action_proxy__ from "private-next-rsc-action-proxy"; +/* __next_internal_action_entry_do_not_use__ $$ACTION_1,$$ACTION_3 */ import { createActionProxy } from "private-next-rsc-action-proxy"; import deleteFromDb from 'db'; const v1 = 'v1'; export function Item({ id1, id2 }) { const v2 = id2; return <> - ; } -export const action = withValidate(($$ACTION_1 = async (...args)=>$$ACTION_2.apply(null, ($$ACTION_1.$$bound || []).concat(args)), __create_action_proxy__("9878bfa39811ca7650992850a8751f9591b6a557", null, $$ACTION_1, $$ACTION_2), $$ACTION_1)); +export const action = withValidate(($$ACTION_1 = async (...args)=>$$ACTION_2.apply(null, ($$ACTION_1.$$bound || []).concat(args)), createActionProxy("9878bfa39811ca7650992850a8751f9591b6a557", null, $$ACTION_1, $$ACTION_2), $$ACTION_1)); export var $$ACTION_2 = async ()=>{}; var $$ACTION_1; \ No newline at end of file diff --git a/packages/next-swc/crates/core/tests/fixture/server-actions/server/20/output.js b/packages/next-swc/crates/core/tests/fixture/server-actions/server/20/output.js index c13e26271b06..4dd595f28635 100644 --- a/packages/next-swc/crates/core/tests/fixture/server-actions/server/20/output.js +++ b/packages/next-swc/crates/core/tests/fixture/server-actions/server/20/output.js @@ -1,4 +1,4 @@ -/* __next_internal_action_entry_do_not_use__ default */ import __create_action_proxy__ from "private-next-rsc-action-proxy"; +/* __next_internal_action_entry_do_not_use__ default */ import { createActionProxy } from "private-next-rsc-action-proxy"; const [foo] = [ null ]; @@ -7,4 +7,4 @@ import ensureServerEntryExports from "private-next-rsc-action-validate"; ensureServerEntryExports([ foo ]); -__create_action_proxy__("c18c215a6b7cdc64bf709f3a714ffdef1bf9651d", null, foo); +createActionProxy("c18c215a6b7cdc64bf709f3a714ffdef1bf9651d", null, foo); diff --git a/packages/next-swc/crates/core/tests/fixture/server-actions/server/21/output.js b/packages/next-swc/crates/core/tests/fixture/server-actions/server/21/output.js index fa187fafc406..27d3ea23c062 100644 --- a/packages/next-swc/crates/core/tests/fixture/server-actions/server/21/output.js +++ b/packages/next-swc/crates/core/tests/fixture/server-actions/server/21/output.js @@ -1,11 +1,11 @@ -/* __next_internal_action_entry_do_not_use__ $$ACTION_1,$$ACTION_3,$$ACTION_5 */ import __create_action_proxy__ from "private-next-rsc-action-proxy"; +/* __next_internal_action_entry_do_not_use__ $$ACTION_1,$$ACTION_3,$$ACTION_5 */ import { createActionProxy } from "private-next-rsc-action-proxy"; import { validator, another } from 'auth'; const x = 1; export default function Page() { const y = 1; return ; } @@ -13,9 +13,9 @@ export async function $$ACTION_1($$ACTION_ARG_0, z) { return x + $$ACTION_ARG_0 + z; } var $$ACTION_0; -validator(($$ACTION_2 = async (...args)=>$$ACTION_3.apply(null, ($$ACTION_2.$$bound || []).concat(args)), __create_action_proxy__("56a859f462d35a297c46a1bbd1e6a9058c104ab8", null, $$ACTION_2, $$ACTION_3), $$ACTION_2)); +validator(($$ACTION_2 = async (...args)=>$$ACTION_3.apply(null, ($$ACTION_2.$$bound || []).concat(args)), createActionProxy("56a859f462d35a297c46a1bbd1e6a9058c104ab8", null, $$ACTION_2, $$ACTION_3), $$ACTION_2)); export var $$ACTION_3 = async ()=>{}; var $$ACTION_2; -another(validator(($$ACTION_4 = async (...args)=>$$ACTION_5.apply(null, ($$ACTION_4.$$bound || []).concat(args)), __create_action_proxy__("1383664d1dc2d9cfe33b88df3fa0eaffef8b99bc", null, $$ACTION_4, $$ACTION_5), $$ACTION_4))); +another(validator(($$ACTION_4 = async (...args)=>$$ACTION_5.apply(null, ($$ACTION_4.$$bound || []).concat(args)), createActionProxy("1383664d1dc2d9cfe33b88df3fa0eaffef8b99bc", null, $$ACTION_4, $$ACTION_5), $$ACTION_4))); export var $$ACTION_5 = async ()=>{}; var $$ACTION_4; diff --git a/packages/next-swc/crates/core/tests/fixture/server-actions/server/22/output.js b/packages/next-swc/crates/core/tests/fixture/server-actions/server/22/output.js index 82e39cc29061..abca995a2b13 100644 --- a/packages/next-swc/crates/core/tests/fixture/server-actions/server/22/output.js +++ b/packages/next-swc/crates/core/tests/fixture/server-actions/server/22/output.js @@ -1,4 +1,4 @@ -/* __next_internal_action_entry_do_not_use__ action,default */ import __create_action_proxy__ from "private-next-rsc-action-proxy"; +/* __next_internal_action_entry_do_not_use__ action,default */ import { createActionProxy } from "private-next-rsc-action-proxy"; import { validator } from 'auth'; export const action = validator(async ()=>{}); export default $$ACTION_0 = validator(async ()=>{}); @@ -8,5 +8,5 @@ ensureServerEntryExports([ action, $$ACTION_0 ]); -__create_action_proxy__("f14702b5a021dd117f7ec7a3c838f397c2046d3b", null, action); -__create_action_proxy__("c18c215a6b7cdc64bf709f3a714ffdef1bf9651d", null, $$ACTION_0); +createActionProxy("f14702b5a021dd117f7ec7a3c838f397c2046d3b", null, action); +createActionProxy("c18c215a6b7cdc64bf709f3a714ffdef1bf9651d", null, $$ACTION_0); diff --git a/packages/next-swc/crates/core/tests/fixture/server-actions/server/23/output.js b/packages/next-swc/crates/core/tests/fixture/server-actions/server/23/output.js index 6425263c5cbe..bd1118debca6 100644 --- a/packages/next-swc/crates/core/tests/fixture/server-actions/server/23/output.js +++ b/packages/next-swc/crates/core/tests/fixture/server-actions/server/23/output.js @@ -1,13 +1,13 @@ -/* __next_internal_action_entry_do_not_use__ $$ACTION_0,$$ACTION_2 */ import __create_action_proxy__ from "private-next-rsc-action-proxy"; +/* __next_internal_action_entry_do_not_use__ $$ACTION_0,$$ACTION_2 */ import { createActionProxy } from "private-next-rsc-action-proxy"; export default function Page({ foo, x, y }) { async function action(...args) { return $$ACTION_0.apply(null, (action.$$bound || []).concat(args)); } - __create_action_proxy__("6d53ce510b2e36499b8f56038817b9bad86cabb4", [ + createActionProxy("6d53ce510b2e36499b8f56038817b9bad86cabb4", [ x ], action, $$ACTION_0); action.bind(null, foo[0], foo[1], foo.x, foo[y]); - const action2 = ($$ACTION_1 = async (...args)=>$$ACTION_2.apply(null, ($$ACTION_1.$$bound || []).concat(args)), __create_action_proxy__("9878bfa39811ca7650992850a8751f9591b6a557", [ + const action2 = ($$ACTION_1 = async (...args)=>$$ACTION_2.apply(null, ($$ACTION_1.$$bound || []).concat(args)), createActionProxy("9878bfa39811ca7650992850a8751f9591b6a557", [ x ], $$ACTION_1, $$ACTION_2), $$ACTION_1); action2.bind(null, foo[0], foo[1], foo.x, foo[y]); diff --git a/packages/next-swc/crates/core/tests/fixture/server-actions/server/3/output.js b/packages/next-swc/crates/core/tests/fixture/server-actions/server/3/output.js index 73d21c0595d9..92fdee096e88 100644 --- a/packages/next-swc/crates/core/tests/fixture/server-actions/server/3/output.js +++ b/packages/next-swc/crates/core/tests/fixture/server-actions/server/3/output.js @@ -1,5 +1,5 @@ // app/send.ts -/* __next_internal_action_entry_do_not_use__ myAction */ import __create_action_proxy__ from "private-next-rsc-action-proxy"; +/* __next_internal_action_entry_do_not_use__ myAction */ import { createActionProxy } from "private-next-rsc-action-proxy"; export async function myAction(a, b, c) { console.log('a'); } @@ -7,4 +7,4 @@ import ensureServerEntryExports from "private-next-rsc-action-validate"; ensureServerEntryExports([ myAction ]); -__create_action_proxy__("e10665baac148856374b2789aceb970f66fec33e", null, myAction); +createActionProxy("e10665baac148856374b2789aceb970f66fec33e", null, myAction); diff --git a/packages/next-swc/crates/core/tests/fixture/server-actions/server/4/output.js b/packages/next-swc/crates/core/tests/fixture/server-actions/server/4/output.js index e76020e52363..8d440c7ac483 100644 --- a/packages/next-swc/crates/core/tests/fixture/server-actions/server/4/output.js +++ b/packages/next-swc/crates/core/tests/fixture/server-actions/server/4/output.js @@ -1,4 +1,4 @@ -/* __next_internal_action_entry_do_not_use__ a,b,c */ import __create_action_proxy__ from "private-next-rsc-action-proxy"; +/* __next_internal_action_entry_do_not_use__ a,b,c */ import { createActionProxy } from "private-next-rsc-action-proxy"; export async function a() {} export async function b() {} export async function c() {} @@ -12,6 +12,6 @@ ensureServerEntryExports([ b, c ]); -__create_action_proxy__("6e7bc104e4d6e7fda190c4a51be969cfd0be6d6d", null, a); -__create_action_proxy__("d1f7eb64271d7c601dfef7d4d7053de1c2ca4338", null, b); -__create_action_proxy__("1ab723c80dcca470e0410b4b2a2fc2bf21f41476", null, c); +createActionProxy("6e7bc104e4d6e7fda190c4a51be969cfd0be6d6d", null, a); +createActionProxy("d1f7eb64271d7c601dfef7d4d7053de1c2ca4338", null, b); +createActionProxy("1ab723c80dcca470e0410b4b2a2fc2bf21f41476", null, c); diff --git a/packages/next-swc/crates/core/tests/fixture/server-actions/server/5/output.js b/packages/next-swc/crates/core/tests/fixture/server-actions/server/5/output.js index f6341e495b68..bdd9979cf0f0 100644 --- a/packages/next-swc/crates/core/tests/fixture/server-actions/server/5/output.js +++ b/packages/next-swc/crates/core/tests/fixture/server-actions/server/5/output.js @@ -1,4 +1,4 @@ -/* __next_internal_action_entry_do_not_use__ $$ACTION_0 */ import __create_action_proxy__ from "private-next-rsc-action-proxy"; +/* __next_internal_action_entry_do_not_use__ $$ACTION_0 */ import { createActionProxy } from "private-next-rsc-action-proxy"; import deleteFromDb from 'db'; const v1 = 'v1'; export function Item({ id1 , id2 , id3 , id4 }) { @@ -6,7 +6,7 @@ export function Item({ id1 , id2 , id3 , id4 }) { async function deleteItem(...args) { return $$ACTION_0.apply(null, (deleteItem.$$bound || []).concat(args)); } - __create_action_proxy__("6d53ce510b2e36499b8f56038817b9bad86cabb4", [ + createActionProxy("6d53ce510b2e36499b8f56038817b9bad86cabb4", [ id1, v2, id3, diff --git a/packages/next-swc/crates/core/tests/fixture/server-actions/server/6/output.js b/packages/next-swc/crates/core/tests/fixture/server-actions/server/6/output.js index 143193607109..2376c11fb7ff 100644 --- a/packages/next-swc/crates/core/tests/fixture/server-actions/server/6/output.js +++ b/packages/next-swc/crates/core/tests/fixture/server-actions/server/6/output.js @@ -1,4 +1,4 @@ -/* __next_internal_action_entry_do_not_use__ $$ACTION_0 */ import __create_action_proxy__ from "private-next-rsc-action-proxy"; +/* __next_internal_action_entry_do_not_use__ $$ACTION_0 */ import { createActionProxy } from "private-next-rsc-action-proxy"; import f, { f1, f2 } from 'foo'; const f3 = 1; var f4; @@ -21,7 +21,7 @@ export function y(p, [p1, { p2 }], ...p3) { async function action(...args) { return $$ACTION_0.apply(null, (action.$$bound || []).concat(args)); } - __create_action_proxy__("6d53ce510b2e36499b8f56038817b9bad86cabb4", [ + createActionProxy("6d53ce510b2e36499b8f56038817b9bad86cabb4", [ f2, f11, p, diff --git a/packages/next-swc/crates/core/tests/fixture/server-actions/server/7/output.js b/packages/next-swc/crates/core/tests/fixture/server-actions/server/7/output.js index 8acc6447ca0a..9b1a083e0907 100644 --- a/packages/next-swc/crates/core/tests/fixture/server-actions/server/7/output.js +++ b/packages/next-swc/crates/core/tests/fixture/server-actions/server/7/output.js @@ -1,10 +1,10 @@ -/* __next_internal_action_entry_do_not_use__ $$ACTION_0 */ import __create_action_proxy__ from "private-next-rsc-action-proxy"; +/* __next_internal_action_entry_do_not_use__ $$ACTION_0 */ import { createActionProxy } from "private-next-rsc-action-proxy"; import deleteFromDb from 'db'; export function Item(product, foo, bar) { async function deleteItem(...args) { return $$ACTION_0.apply(null, (deleteItem.$$bound || []).concat(args)); } - __create_action_proxy__("6d53ce510b2e36499b8f56038817b9bad86cabb4", [ + createActionProxy("6d53ce510b2e36499b8f56038817b9bad86cabb4", [ product.id, product?.foo, product.bar.baz, diff --git a/packages/next-swc/crates/core/tests/fixture/server-actions/server/8/output.js b/packages/next-swc/crates/core/tests/fixture/server-actions/server/8/output.js index 483c7aa7917d..ada9615ff168 100644 --- a/packages/next-swc/crates/core/tests/fixture/server-actions/server/8/output.js +++ b/packages/next-swc/crates/core/tests/fixture/server-actions/server/8/output.js @@ -1,8 +1,8 @@ -/* __next_internal_action_entry_do_not_use__ $$ACTION_0 */ import __create_action_proxy__ from "private-next-rsc-action-proxy"; +/* __next_internal_action_entry_do_not_use__ $$ACTION_0 */ import { createActionProxy } from "private-next-rsc-action-proxy"; async function myAction(...args) { return $$ACTION_0.apply(null, (myAction.$$bound || []).concat(args)); } -__create_action_proxy__("6d53ce510b2e36499b8f56038817b9bad86cabb4", null, myAction, $$ACTION_0); +createActionProxy("6d53ce510b2e36499b8f56038817b9bad86cabb4", null, myAction, $$ACTION_0); export async function $$ACTION_0(a, b, c) { // comment 'use strict'; diff --git a/packages/next-swc/crates/core/tests/fixture/server-actions/server/9/output.js b/packages/next-swc/crates/core/tests/fixture/server-actions/server/9/output.js index 6ee2eb28ae9b..d1c4908b8871 100644 --- a/packages/next-swc/crates/core/tests/fixture/server-actions/server/9/output.js +++ b/packages/next-swc/crates/core/tests/fixture/server-actions/server/9/output.js @@ -1,5 +1,5 @@ // app/send.ts -/* __next_internal_action_entry_do_not_use__ foo,baz,default */ import __create_action_proxy__ from "private-next-rsc-action-proxy"; +/* __next_internal_action_entry_do_not_use__ foo,baz,default */ import { createActionProxy } from "private-next-rsc-action-proxy"; async function foo() {} export { foo }; async function bar() {} @@ -12,6 +12,6 @@ ensureServerEntryExports([ bar, qux ]); -__create_action_proxy__("ab21efdafbe611287bc25c0462b1e0510d13e48b", null, foo); -__create_action_proxy__("050e3854b72b19e3c7e3966a67535543a90bf7e0", null, bar); -__create_action_proxy__("c18c215a6b7cdc64bf709f3a714ffdef1bf9651d", null, qux); +createActionProxy("ab21efdafbe611287bc25c0462b1e0510d13e48b", null, foo); +createActionProxy("050e3854b72b19e3c7e3966a67535543a90bf7e0", null, bar); +createActionProxy("c18c215a6b7cdc64bf709f3a714ffdef1bf9651d", null, qux); diff --git a/packages/next/src/build/webpack/loaders/next-flight-loader/action-proxy.ts b/packages/next/src/build/webpack/loaders/next-flight-loader/action-proxy.ts index c89eb0f90c47..c85600167cc1 100644 --- a/packages/next/src/build/webpack/loaders/next-flight-loader/action-proxy.ts +++ b/packages/next/src/build/webpack/loaders/next-flight-loader/action-proxy.ts @@ -1,4 +1,4 @@ -export default function createActionProxy( +export function createActionProxy( id: string, bound: null | any[], action: any,