From afe5bb57e37a7763f84bd6bce62a6155c976e184 Mon Sep 17 00:00:00 2001 From: Zack Tanner Date: Mon, 23 Oct 2023 21:15:01 -0700 Subject: [PATCH 1/2] taint should enable experimental react in turbopack --- packages/next-swc/crates/next-core/src/next_config.rs | 5 +++++ packages/next-swc/crates/next-core/src/next_import_map.rs | 4 +++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/packages/next-swc/crates/next-core/src/next_config.rs b/packages/next-swc/crates/next-core/src/next_config.rs index f7ed3693e1ad4..3430a1b5549f1 100644 --- a/packages/next-swc/crates/next-core/src/next_config.rs +++ b/packages/next-swc/crates/next-core/src/next_config.rs @@ -753,6 +753,11 @@ impl NextConfig { pub async fn enable_ppr(self: Vc) -> Result> { Ok(Vc::cell(self.await?.experimental.ppr.unwrap_or(false))) } + + #[turbo_tasks::function] + pub async fn enable_taint(self: Vc) -> Result> { + Ok(Vc::cell(self.await?.experimental.taint.unwrap_or(false))) + } } fn next_configs() -> Vc> { diff --git a/packages/next-swc/crates/next-core/src/next_import_map.rs b/packages/next-swc/crates/next-core/src/next_import_map.rs index 3dda1728e18fa..562cf934db61d 100644 --- a/packages/next-swc/crates/next-core/src/next_import_map.rs +++ b/packages/next-swc/crates/next-core/src/next_import_map.rs @@ -94,6 +94,7 @@ pub async fn get_next_client_import_map( ClientContextType::App { app_dir } => { let react_flavor = if *next_config.enable_server_actions().await? || *next_config.enable_ppr().await? + || *next_config.enable_taint().await? { "-experimental" } else { @@ -646,7 +647,8 @@ async fn rsc_aliases( ) -> Result<()> { let server_actions = *next_config.enable_server_actions().await?; let ppr = *next_config.enable_ppr().await?; - let react_channel = if server_actions || ppr { + let taint = *next_config.enable_taint().await?; + let react_channel = if server_actions || ppr || taint { "-experimental" } else { "" From 12641ca1ca9af5da5ae1b43347e6e455a87b2a14 Mon Sep 17 00:00:00 2001 From: Zack Tanner Date: Mon, 23 Oct 2023 23:07:16 -0700 Subject: [PATCH 2/2] remove `enable_server_actions` flag (#57317) Since this is now enabled as of https://github.com/vercel/next.js/pull/57145 --- packages/next-swc/crates/next-api/src/app.rs | 8 ------- .../crates/next-api/src/server_actions.rs | 17 --------------- .../next-core/src/next_client/transforms.rs | 5 +---- .../crates/next-core/src/next_config.rs | 7 ------- .../crates/next-core/src/next_import_map.rs | 21 +++++++------------ .../next-core/src/next_server/transforms.rs | 9 ++------ 6 files changed, 10 insertions(+), 57 deletions(-) diff --git a/packages/next-swc/crates/next-api/src/app.rs b/packages/next-swc/crates/next-api/src/app.rs index 6e1af53a14ed4..eab5ef193d0e7 100644 --- a/packages/next-swc/crates/next-api/src/app.rs +++ b/packages/next-swc/crates/next-api/src/app.rs @@ -830,10 +830,6 @@ impl AppEndpoint { NextRuntime::Edge, Vc::upcast(this.app_project.edge_rsc_module_context()), Vc::upcast(chunking_context), - this.app_project - .project() - .next_config() - .enable_server_actions(), ) .await?; server_assets.push(manifest); @@ -984,10 +980,6 @@ impl AppEndpoint { NextRuntime::NodeJs, Vc::upcast(this.app_project.rsc_module_context()), Vc::upcast(this.app_project.project().server_chunking_context()), - this.app_project - .project() - .next_config() - .enable_server_actions(), ) .await?; server_assets.push(manifest); diff --git a/packages/next-swc/crates/next-api/src/server_actions.rs b/packages/next-swc/crates/next-api/src/server_actions.rs index 3ef3583dee0b5..412e99ff6104d 100644 --- a/packages/next-swc/crates/next-api/src/server_actions.rs +++ b/packages/next-swc/crates/next-api/src/server_actions.rs @@ -49,27 +49,10 @@ pub(crate) async fn create_server_actions_manifest( runtime: NextRuntime, asset_context: Vc>, chunking_context: Vc>, - enable_server_actions: Vc, ) -> Result<( Option>>, Vc>, )> { - // If actions aren't enabled, then there's no need to scan the module graph. We - // still need to generate an empty manifest so that the TS side can merge - // the manifest later on. - if !*enable_server_actions.await? { - let manifest = build_manifest( - node_root, - pathname, - page_name, - runtime, - ModuleActionMap::empty(), - Default::default(), - ) - .await?; - return Ok((None, manifest)); - } - let actions = get_actions(Vc::upcast(entry)); let loader = build_server_actions_loader(node_root, page_name, actions, asset_context).await?; let Some(evaluable) = Vc::try_resolve_sidecast::>(loader).await? diff --git a/packages/next-swc/crates/next-core/src/next_client/transforms.rs b/packages/next-swc/crates/next-core/src/next_client/transforms.rs index 15a07842fdf48..b387763cf01fb 100644 --- a/packages/next-swc/crates/next-core/src/next_client/transforms.rs +++ b/packages/next-swc/crates/next-core/src/next_client/transforms.rs @@ -24,7 +24,6 @@ pub async fn get_next_client_transforms_rules( let mut rules = vec![]; let modularize_imports_config = &next_config.await?.modularize_imports; - let enable_server_actions = *next_config.enable_server_actions().await?; if let Some(modularize_imports_config) = modularize_imports_config { rules.push(get_next_modularize_imports_rule(modularize_imports_config)); } @@ -39,9 +38,7 @@ pub async fn get_next_client_transforms_rules( Some(pages_dir) } ClientContextType::App { .. } => { - if enable_server_actions { - rules.push(get_server_actions_transform_rule(ActionsTransform::Client)); - } + rules.push(get_server_actions_transform_rule(ActionsTransform::Client)); None } ClientContextType::Fallback | ClientContextType::Other => None, diff --git a/packages/next-swc/crates/next-core/src/next_config.rs b/packages/next-swc/crates/next-core/src/next_config.rs index 3430a1b5549f1..887baca13e79b 100644 --- a/packages/next-swc/crates/next-core/src/next_config.rs +++ b/packages/next-swc/crates/next-core/src/next_config.rs @@ -742,13 +742,6 @@ impl NextConfig { )))) } - #[turbo_tasks::function] - pub async fn enable_server_actions(self: Vc) -> Result> { - Ok(Vc::cell( - self.await?.experimental.server_actions.unwrap_or(false), - )) - } - #[turbo_tasks::function] pub async fn enable_ppr(self: Vc) -> Result> { Ok(Vc::cell(self.await?.experimental.ppr.unwrap_or(false))) diff --git a/packages/next-swc/crates/next-core/src/next_import_map.rs b/packages/next-swc/crates/next-core/src/next_import_map.rs index 562cf934db61d..f25b6d6f097f1 100644 --- a/packages/next-swc/crates/next-core/src/next_import_map.rs +++ b/packages/next-swc/crates/next-core/src/next_import_map.rs @@ -92,14 +92,12 @@ pub async fn get_next_client_import_map( ); } ClientContextType::App { app_dir } => { - let react_flavor = if *next_config.enable_server_actions().await? - || *next_config.enable_ppr().await? - || *next_config.enable_taint().await? - { - "-experimental" - } else { - "" - }; + let react_flavor = + if *next_config.enable_ppr().await? || *next_config.enable_taint().await? { + "-experimental" + } else { + "" + }; import_map.insert_exact_alias( "react", @@ -645,14 +643,9 @@ async fn rsc_aliases( runtime: NextRuntime, next_config: Vc, ) -> Result<()> { - let server_actions = *next_config.enable_server_actions().await?; let ppr = *next_config.enable_ppr().await?; let taint = *next_config.enable_taint().await?; - let react_channel = if server_actions || ppr || taint { - "-experimental" - } else { - "" - }; + let react_channel = if ppr || taint { "-experimental" } else { "" }; let mut alias = indexmap! { "react" => format!("next/dist/compiled/react{react_channel}"), diff --git a/packages/next-swc/crates/next-core/src/next_server/transforms.rs b/packages/next-swc/crates/next-core/src/next_server/transforms.rs index 63a58d59a8420..85533ca34ca26 100644 --- a/packages/next-swc/crates/next-core/src/next_server/transforms.rs +++ b/packages/next-swc/crates/next-core/src/next_server/transforms.rs @@ -25,7 +25,6 @@ pub async fn get_next_server_transforms_rules( let mut rules = vec![]; let modularize_imports_config = &next_config.await?.modularize_imports; - let enable_server_actions = *next_config.enable_server_actions().await?; if let Some(modularize_imports_config) = modularize_imports_config { rules.push(get_next_modularize_imports_rule(modularize_imports_config)); } @@ -40,17 +39,13 @@ pub async fn get_next_server_transforms_rules( (false, Some(pages_dir)) } ServerContextType::AppSSR { .. } => { - if enable_server_actions { - rules.push(get_server_actions_transform_rule(ActionsTransform::Server)); - } + rules.push(get_server_actions_transform_rule(ActionsTransform::Server)); (false, None) } ServerContextType::AppRSC { client_transition, .. } => { - if enable_server_actions { - rules.push(get_server_actions_transform_rule(ActionsTransform::Server)); - } + rules.push(get_server_actions_transform_rule(ActionsTransform::Server)); if let Some(client_transition) = client_transition { rules.push(get_next_css_client_reference_transforms_rule( client_transition,