diff --git a/packages/next-swc/crates/next-core/src/next_client/context.rs b/packages/next-swc/crates/next-core/src/next_client/context.rs index c60e88ee87ad2..dacbc5b36af90 100644 --- a/packages/next-swc/crates/next-core/src/next_client/context.rs +++ b/packages/next-swc/crates/next-core/src/next_client/context.rs @@ -19,6 +19,7 @@ use turbo_binding::{ free_var_references, }, dev::DevChunkingContextVc, + ecmascript::EcmascriptInputTransform, env::ProcessEnvAssetVc, node::execution_context::ExecutionContextVc, turbopack::{ @@ -175,6 +176,9 @@ pub async fn get_client_module_options_context( }; let module_options_context = ModuleOptionsContext { + custom_ecmascript_transforms: vec![EcmascriptInputTransform::ServerDirective( + StringVc::cell("TODO".to_string()), + )], preset_env_versions: Some(env), execution_context: Some(execution_context), ..Default::default() diff --git a/packages/next-swc/crates/next-core/src/next_server/context.rs b/packages/next-swc/crates/next-core/src/next_server/context.rs index 0eb7bba03dbf7..8f58f77f23875 100644 --- a/packages/next-swc/crates/next-core/src/next_server/context.rs +++ b/packages/next-swc/crates/next-core/src/next_server/context.rs @@ -259,6 +259,9 @@ pub async fn get_server_module_options_context( } ServerContextType::AppSSR { .. } => { let module_options_context = ModuleOptionsContext { + custom_ecmascript_transforms: vec![EcmascriptInputTransform::ServerDirective( + StringVc::cell("TODO".to_string()), + )], execution_context: Some(execution_context), ..Default::default() }; @@ -279,9 +282,12 @@ pub async fn get_server_module_options_context( } ServerContextType::AppRSC { .. } => { let module_options_context = ModuleOptionsContext { - custom_ecmascript_transforms: vec![EcmascriptInputTransform::ClientDirective( - StringVc::cell("server-to-client".to_string()), - )], + custom_ecmascript_transforms: vec![ + EcmascriptInputTransform::ClientDirective(StringVc::cell( + "server-to-client".to_string(), + )), + EcmascriptInputTransform::ServerDirective(StringVc::cell("TODO".to_string())), + ], execution_context: Some(execution_context), ..Default::default() }; diff --git a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/use-server/input/app/action.tsx b/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/use-server/input/app/action.tsx new file mode 100644 index 0000000000000..41a47cf25dfde --- /dev/null +++ b/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/use-server/input/app/action.tsx @@ -0,0 +1,5 @@ +'use server' + +export default async function Action() { + return 42 +} diff --git a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/use-server/input/app/layout.tsx b/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/use-server/input/app/layout.tsx new file mode 100644 index 0000000000000..7f4de05aba9b3 --- /dev/null +++ b/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/use-server/input/app/layout.tsx @@ -0,0 +1,7 @@ +export default function RootLayout({ children }: { children: any }) { + return ( + +
{children} + + ); +} diff --git a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/use-server/input/app/page.tsx b/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/use-server/input/app/page.tsx new file mode 100644 index 0000000000000..1ebdc1d7496c3 --- /dev/null +++ b/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/use-server/input/app/page.tsx @@ -0,0 +1,15 @@ +import Test from './test' + +export default async function Page() { + let action + try { + await import('./action') + } catch (e) { + action = e.toString() + } + return ( +