Repository: vercel/next.js
Pull request: [turbopack] Remove uses of `Value<ClientContextType>` by making `ClientContextType` a TaskInput

Refactor ClientContextType to use TaskInput instead of Value wrapper

### Why?
The `Value<>` type is confusing and error prone, lets destroy it!

As discussed over slack, `turbo_tasks::Value` type always implements `is_resolved` as `true` and `is_transient` as `false` which is incorrect and can enable smuggling transient vcs into turbo tasks. 

• https://vercel.slack.com/archives/C03EWR7LGEN/p1743456121241529
• https://vercel.slack.com/archives/C04NGV98TPS/p1743455453764879


Closes PACK-4775

Changed files:
filename: crates/next-api/src/app.rs
patch: @@ -207,7 +207,7 @@ impl AppProject {
             self.project().project_path(),
             self.project().execution_context(),
             self.project().client_compile_time_info().environment(),
-            Value::new(self.client_ty().owned().await?),
+            self.client_ty().owned().await?,
             self.project().next_mode(),
             self.project().next_config(),
             self.project().encryption_key(),
@@ -219,7 +219,7 @@ impl AppProject {
     async fn client_resolve_options_context(self: Vc<Self>) -> Result<Vc<ResolveOptionsContext>> {
         Ok(get_client_resolve_options_context(
             self.project().project_path(),
-            Value::new(self.client_ty().owned().await?),
+            self.client_ty().owned().await?,
             self.project().next_mode(),
             self.project().next_config(),
             self.project().execution_context(),
@@ -784,7 +784,7 @@ impl AppProject {
     async fn client_runtime_entries(self: Vc<Self>) -> Result<Vc<EvaluatableAssets>> {
         Ok(get_client_runtime_entries(
             self.project().project_path(),
-            Value::new(self.client_ty().owned().await?),
+            self.client_ty().owned().await?,
             self.project().next_mode(),
             self.project().next_config(),
             self.project().execution_context(),

filename: crates/next-api/src/pages.rs
patch: @@ -336,9 +336,9 @@ impl PagesProject {
             self.project().project_path(),
             self.project().execution_context(),
             self.project().client_compile_time_info().environment(),
-            Value::new(ClientContextType::Pages {
+            ClientContextType::Pages {
                 pages_dir: self.pages_dir().to_resolved().await?,
-            }),
+            },
             self.project().next_mode(),
             self.project().next_config(),
             self.project().encryption_key(),
@@ -350,9 +350,9 @@ impl PagesProject {
     async fn client_resolve_options_context(self: Vc<Self>) -> Result<Vc<ResolveOptionsContext>> {
         Ok(get_client_resolve_options_context(
             self.project().project_path(),
-            Value::new(ClientContextType::Pages {
+            ClientContextType::Pages {
                 pages_dir: self.pages_dir().to_resolved().await?,
-            }),
+            },
             self.project().next_mode(),
             self.project().next_config(),
             self.project().execution_context(),
@@ -566,9 +566,9 @@ impl PagesProject {
     async fn client_runtime_entries(self: Vc<Self>) -> Result<Vc<EvaluatableAssets>> {
         let client_runtime_entries = get_client_runtime_entries(
             self.project().project_path(),
-            Value::new(ClientContextType::Pages {
+            ClientContextType::Pages {
                 pages_dir: self.pages_dir().to_resolved().await?,
-            }),
+            },
             self.project().next_mode(),
             self.project().next_config(),
             self.project().execution_context(),

filename: crates/next-core/src/next_client/context.rs
patch: @@ -2,7 +2,7 @@ use std::iter::once;
 
 use anyhow::Result;
 use turbo_rcstr::{RcStr, rcstr};
-use turbo_tasks::{FxIndexMap, OptionVcExt, ResolvedVc, Value, Vc};
+use turbo_tasks::{FxIndexMap, OptionVcExt, ResolvedVc, TaskInput, Value, Vc};
 use turbo_tasks_env::EnvMap;
 use turbo_tasks_fs::FileSystemPath;
 use turbopack::{
@@ -139,8 +139,8 @@ pub async fn get_client_compile_time_info(
     .await
 }
 
-#[turbo_tasks::value(shared, serialization = "auto_for_input")]
-#[derive(Debug, Copy, Clone, Hash)]
+#[turbo_tasks::value(shared)]
+#[derive(Debug, Copy, Clone, Hash, TaskInput)]
 pub enum ClientContextType {
     Pages {
         pages_dir: ResolvedVc<FileSystemPath>,
@@ -155,7 +155,7 @@ pub enum ClientContextType {
 #[turbo_tasks::function]
 pub async fn get_client_resolve_options_context(
     project_path: ResolvedVc<FileSystemPath>,
-    ty: Value<ClientContextType>,
+    ty: ClientContextType,
     mode: Vc<NextMode>,
     next_config: Vc<NextConfig>,
     execution_context: Vc<ExecutionContext>,
@@ -231,7 +231,7 @@ pub async fn get_client_module_options_context(
     project_path: ResolvedVc<FileSystemPath>,
     execution_context: ResolvedVc<ExecutionContext>,
     env: ResolvedVc<Environment>,
-    ty: Value<ClientContextType>,
+    ty: ClientContextType,
     mode: Vc<NextMode>,
     next_config: Vc<NextConfig>,
     encryption_key: ResolvedVc<RcStr>,
@@ -291,11 +291,9 @@ pub async fn get_client_module_options_context(
     let target_browsers = env.runtime_versions();
 
     let mut next_client_rules =
-        get_next_client_transforms_rules(next_config, ty.into_value(), mode, false, encryption_key)
-            .await?;
+        get_next_client_transforms_rules(next_config, ty, mode, false, encryption_key).await?;
     let foreign_next_client_rules =
-        get_next_client_transforms_rules(next_config, ty.into_value(), mode, true, encryption_key)
-            .await?;
+        get_next_client_transforms_rules(next_config, ty, mode, true, encryption_key).await?;
     let additional_rules: Vec<ModuleRule> = vec![
         get_swc_ecma_transform_plugin_rule(next_config, project_path).await?,
         get_relay_transform_rule(next_config, project_path).await?,
@@ -500,7 +498,7 @@ pub fn get_client_assets_path(client_root: Vc<FileSystemPath>) -> Vc<FileSystemP
 #[turbo_tasks::function]
 pub async fn get_client_runtime_entries(
     project_root: Vc<FileSystemPath>,
-    ty: Value<ClientContextType>,
+    ty: ClientContextType,
     mode: Vc<NextMode>,
     next_config: Vc<NextConfig>,
     execution_context: Vc<ExecutionContext>,
@@ -529,7 +527,7 @@ pub async fn get_client_runtime_entries(
         };
     }
 
-    if matches!(*ty, ClientContextType::App { .. },) {
+    if matches!(ty, ClientContextType::App { .. },) {
         runtime_entries.push(
             RuntimeEntry::Request(
                 Request::parse(Value::new(Pattern::Constant(rcstr!(

filename: crates/next-core/src/next_import_map.rs
patch: @@ -91,7 +91,7 @@ const EDGE_UNSUPPORTED_NODE_INTERNALS: [&str; 44] = [
 #[turbo_tasks::function]
 pub async fn get_next_client_import_map(
     project_path: ResolvedVc<FileSystemPath>,
-    ty: Value<ClientContextType>,
+    ty: ClientContextType,
     next_config: Vc<NextConfig>,
     next_mode: Vc<NextMode>,
     execution_context: Vc<ExecutionContext>,
@@ -118,7 +118,7 @@ pub async fn get_next_client_import_map(
     )
     .await?;
 
-    match ty.into_value() {
+    match ty {
         ClientContextType::Pages { .. } => {}
         ClientContextType::App { app_dir } => {
             let react_flavor = if *next_config.enable_ppr().await?
@@ -236,7 +236,7 @@ pub async fn get_next_client_import_map(
         },
     );
 
-    match ty.into_value() {
+    match ty {
         ClientContextType::Pages { .. }
         | ClientContextType::App { .. }
         | ClientContextType::Fallback => {
@@ -259,12 +259,10 @@ pub async fn get_next_client_import_map(
 /// Computes the Next-specific client fallback import map, which provides
 /// polyfills to Node.js externals.
 #[turbo_tasks::function]
-pub async fn get_next_client_fallback_import_map(
-    ty: Value<ClientContextType>,
-) -> Result<Vc<ImportMap>> {
+pub async fn get_next_client_fallback_import_map(ty: ClientContextType) -> Result<Vc<ImportMap>> {
     let mut import_map = ImportMap::empty();
 
-    match ty.into_value() {
+    match ty {
         ClientContextType::Pages {
             pages_dir: context_dir,
         }