Skip to content

Commit 1cad98f

Browse files
committed
Remove uses of Value<..> instead make the payload a Taskinput
1 parent 8172586 commit 1cad98f

File tree

12 files changed

+69
-48
lines changed

12 files changed

+69
-48
lines changed

turbopack/crates/turbopack-browser/src/ecmascript/evaluate/chunk.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ impl EcmascriptBrowserEvaluateChunk {
228228
.await?,
229229
);
230230

231-
Ok(AssetIdent::new(Value::new(ident)))
231+
Ok(AssetIdent::new(ident))
232232
}
233233

234234
#[turbo_tasks::function]

turbopack/crates/turbopack-browser/src/ecmascript/list/asset.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ impl OutputAsset for EcmascriptDevChunkList {
8787
// ident, because it must remain stable whenever a chunk is added or
8888
// removed from the list.
8989

90-
let ident = AssetIdent::new(Value::new(ident));
90+
let ident = AssetIdent::new(ident);
9191
Ok(this
9292
.chunking_context
9393
.chunk_path(Some(Vc::upcast(self)), ident, rcstr!(".js")))

turbopack/crates/turbopack-core/src/chunk/chunking_context.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,17 @@ pub struct EntryChunkGroupResult {
109109
}
110110

111111
#[derive(
112-
Default, Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize, TraceRawVcs, NonLocalValue,
112+
Default,
113+
Debug,
114+
Clone,
115+
PartialEq,
116+
Eq,
117+
Hash,
118+
Serialize,
119+
Deserialize,
120+
TraceRawVcs,
121+
NonLocalValue,
122+
TaskInput,
113123
)]
114124
pub struct ChunkingConfig {
115125
/// Try to avoid creating more than 1 chunk smaller than this size.

turbopack/crates/turbopack-core/src/ident.rs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@ use anyhow::Result;
44
use once_cell::sync::Lazy;
55
use regex::Regex;
66
use turbo_rcstr::RcStr;
7-
use turbo_tasks::{ResolvedVc, Value, ValueToString, Vc};
7+
use turbo_tasks::{ResolvedVc, TaskInput, ValueToString, Vc};
88
use turbo_tasks_fs::FileSystemPath;
99
use turbo_tasks_hash::{DeterministicHash, Xxh3Hash64Hasher, encode_hex, hash_xxh3_hash64};
1010

1111
use crate::resolve::ModulePart;
1212

1313
#[turbo_tasks::value(serialization = "auto_for_input")]
14-
#[derive(Clone, Debug, Hash)]
14+
#[derive(Clone, Debug, Hash, TaskInput)]
1515
pub struct AssetIdent {
1616
/// The primary path of the asset
1717
pub path: ResolvedVc<FileSystemPath>,
@@ -119,7 +119,7 @@ impl ValueToString for AssetIdent {
119119
#[turbo_tasks::value_impl]
120120
impl AssetIdent {
121121
#[turbo_tasks::function]
122-
pub async fn new(ident: Value<AssetIdent>) -> Result<Vc<Self>> {
122+
pub async fn new(ident: AssetIdent) -> Result<Vc<Self>> {
123123
debug_assert!(
124124
ident.query.is_empty() || ident.query.starts_with("?"),
125125
"query should be empty or start with a `?`"
@@ -128,13 +128,13 @@ impl AssetIdent {
128128
ident.fragment.is_empty() || ident.fragment.starts_with("#"),
129129
"query should be empty or start with a `?`"
130130
);
131-
Ok(ident.into_value().cell())
131+
Ok(ident.cell())
132132
}
133133

134134
/// Creates an [AssetIdent] from a [Vc<FileSystemPath>]
135135
#[turbo_tasks::function]
136136
pub fn from_path(path: ResolvedVc<FileSystemPath>) -> Vc<Self> {
137-
Self::new(Value::new(AssetIdent {
137+
Self::new(AssetIdent {
138138
path,
139139
query: RcStr::default(),
140140
fragment: RcStr::default(),
@@ -143,57 +143,57 @@ impl AssetIdent {
143143
parts: Vec::new(),
144144
layer: None,
145145
content_type: None,
146-
}))
146+
})
147147
}
148148

149149
#[turbo_tasks::function]
150150
pub fn with_query(&self, query: RcStr) -> Vc<Self> {
151151
let mut this = self.clone();
152152
this.query = query;
153-
Self::new(Value::new(this))
153+
Self::new(this)
154154
}
155155

156156
#[turbo_tasks::function]
157157
pub fn with_fragment(&self, fragment: RcStr) -> Vc<Self> {
158158
let mut this = self.clone();
159159
this.fragment = fragment;
160-
Self::new(Value::new(this))
160+
Self::new(this)
161161
}
162162

163163
#[turbo_tasks::function]
164164
pub fn with_modifier(&self, modifier: RcStr) -> Vc<Self> {
165165
let mut this = self.clone();
166166
this.add_modifier(modifier);
167-
Self::new(Value::new(this))
167+
Self::new(this)
168168
}
169169

170170
#[turbo_tasks::function]
171171
pub fn with_part(&self, part: ModulePart) -> Vc<Self> {
172172
let mut this = self.clone();
173173
this.parts.push(part);
174-
Self::new(Value::new(this))
174+
Self::new(this)
175175
}
176176

177177
#[turbo_tasks::function]
178178
pub fn with_path(&self, path: ResolvedVc<FileSystemPath>) -> Vc<Self> {
179179
let mut this = self.clone();
180180
this.path = path;
181-
Self::new(Value::new(this))
181+
Self::new(this)
182182
}
183183

184184
#[turbo_tasks::function]
185185
pub fn with_layer(&self, layer: RcStr) -> Vc<Self> {
186186
let mut this = self.clone();
187187
debug_assert!(!layer.is_empty(), "cannot set empty layers names");
188188
this.layer = Some(layer);
189-
Self::new(Value::new(this))
189+
Self::new(this)
190190
}
191191

192192
#[turbo_tasks::function]
193193
pub fn with_content_type(&self, content_type: RcStr) -> Vc<Self> {
194194
let mut this = self.clone();
195195
this.content_type = Some(content_type);
196-
Self::new(Value::new(this))
196+
Self::new(this)
197197
}
198198

199199
#[turbo_tasks::function]
@@ -207,7 +207,7 @@ impl AssetIdent {
207207
pub async fn rename_as(&self, pattern: RcStr) -> Result<Vc<Self>> {
208208
let mut this = self.clone();
209209
this.rename_as_ref(&pattern).await?;
210-
Ok(Self::new(Value::new(this)))
210+
Ok(Self::new(this))
211211
}
212212

213213
#[turbo_tasks::function]

turbopack/crates/turbopack-core/src/resolve/mod.rs

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use tracing::{Instrument, Level};
1313
use turbo_rcstr::{RcStr, rcstr};
1414
use turbo_tasks::{
1515
FxIndexMap, FxIndexSet, NonLocalValue, ReadRef, ResolvedVc, SliceMap, TaskInput,
16-
TryJoinIterExt, Value, ValueToString, Vc, trace::TraceRawVcs,
16+
TryJoinIterExt, ValueToString, Vc, trace::TraceRawVcs,
1717
};
1818
use turbo_tasks_fs::{
1919
FileSystemEntryType, FileSystemPath, RealPathResult, util::normalize_request,
@@ -489,6 +489,12 @@ pub struct RequestKey {
489489
pub conditions: BTreeMap<String, bool>,
490490
}
491491

492+
impl TaskInput for RequestKey {
493+
fn is_transient(&self) -> bool {
494+
false
495+
}
496+
}
497+
492498
impl Display for RequestKey {
493499
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
494500
if let Some(request) = &self.request {
@@ -1016,9 +1022,8 @@ impl ResolveResult {
10161022
pub fn with_replaced_request_key(
10171023
&self,
10181024
old_request_key: RcStr,
1019-
request_key: Value<RequestKey>,
1025+
request_key: RequestKey,
10201026
) -> Result<Vc<Self>> {
1021-
let request_key = request_key.into_value();
10221027
let new_primary = self
10231028
.primary
10241029
.iter()
@@ -1323,13 +1328,13 @@ pub async fn find_context_file(
13231328
pub async fn find_context_file_or_package_key(
13241329
lookup_path: Vc<FileSystemPath>,
13251330
names: Vc<Vec<RcStr>>,
1326-
package_key: Value<RcStr>,
1331+
package_key: RcStr,
13271332
) -> Result<Vc<FindContextFileResult>> {
13281333
let mut refs = Vec::new();
13291334
let package_json_path = lookup_path.join(rcstr!("package.json"));
13301335
if let Some(package_json_path) = exists(package_json_path, &mut refs).await?
13311336
&& let Some(json) = &*read_package_json(*package_json_path).await?
1332-
&& json.get(&**package_key).is_some()
1337+
&& json.get(&*package_key).is_some()
13331338
{
13341339
return Ok(FindContextFileResult::Found(package_json_path, refs).into());
13351340
}
@@ -2440,7 +2445,7 @@ async fn apply_in_package(
24402445
.with_fragment(fragment.clone()),
24412446
options,
24422447
)
2443-
.with_replaced_request_key(value.into(), Value::new(request_key))
2448+
.with_replaced_request_key(value.into(), request_key)
24442449
.with_affecting_sources(refs.into_iter().map(|src| *src).collect()),
24452450
));
24462451
}
@@ -2597,7 +2602,7 @@ async fn resolve_module_request(
25972602

25982603
let module_result =
25992604
merge_results_with_affecting_sources(results, result.affecting_sources.clone())
2600-
.with_replaced_request_key(rcstr!("."), Value::new(RequestKey::new(module.into())));
2605+
.with_replaced_request_key(rcstr!("."), RequestKey::new(module.into()));
26012606

26022607
if options_value.prefer_relative {
26032608
let module_prefix: RcStr = format!("./{module}").into();
@@ -2612,7 +2617,7 @@ async fn resolve_module_request(
26122617
let relative_result =
26132618
Box::pin(resolve_internal_inline(lookup_path, *relative, options)).await?;
26142619
let relative_result = relative_result
2615-
.with_replaced_request_key(module_prefix, Value::new(RequestKey::new(module.into())));
2620+
.with_replaced_request_key(module_prefix, RequestKey::new(module.into()));
26162621

26172622
Ok(merge_results(vec![relative_result, module_result]))
26182623
} else {

turbopack/crates/turbopack-css/src/chunk/mod.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@ use anyhow::{Result, bail};
77
use swc_core::common::pass::Either;
88
use turbo_rcstr::{RcStr, rcstr};
99
use turbo_tasks::{
10-
FxIndexSet, ResolvedVc, TryFlatJoinIterExt, TryJoinIterExt, Value, ValueDefault, ValueToString,
11-
Vc,
10+
FxIndexSet, ResolvedVc, TryFlatJoinIterExt, TryJoinIterExt, ValueDefault, ValueToString, Vc,
1211
};
1312
use turbo_tasks_fs::{
1413
File, FileSystem, FileSystemPath,
@@ -201,7 +200,7 @@ impl CssChunk {
201200
content_type: None,
202201
};
203202

204-
Ok(AssetIdent::new(Value::new(ident)))
203+
Ok(AssetIdent::new(ident))
205204
}
206205
}
207206

turbopack/crates/turbopack-ecmascript-runtime/src/runtime_type.rs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,18 @@
11
use serde::{Deserialize, Serialize};
2-
use turbo_tasks::{NonLocalValue, trace::TraceRawVcs};
2+
use turbo_tasks::{NonLocalValue, TaskInput, trace::TraceRawVcs};
33

44
#[derive(
5-
Serialize, Deserialize, Debug, Clone, Copy, Hash, PartialEq, Eq, TraceRawVcs, NonLocalValue,
5+
Serialize,
6+
Deserialize,
7+
Debug,
8+
Clone,
9+
Copy,
10+
Hash,
11+
PartialEq,
12+
Eq,
13+
TraceRawVcs,
14+
NonLocalValue,
15+
TaskInput,
616
)]
717
pub enum RuntimeType {
818
Development,

turbopack/crates/turbopack-ecmascript/src/chunk/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use std::fmt::Write;
1010

1111
use anyhow::Result;
1212
use turbo_rcstr::{RcStr, rcstr};
13-
use turbo_tasks::{ResolvedVc, TryFlatJoinIterExt, TryJoinIterExt, Value, ValueToString, Vc};
13+
use turbo_tasks::{ResolvedVc, TryFlatJoinIterExt, TryJoinIterExt, ValueToString, Vc};
1414
use turbo_tasks_fs::FileSystem;
1515
use turbopack_core::{
1616
chunk::{Chunk, ChunkItem, ChunkItems, ChunkingContext, ModuleIds},
@@ -120,7 +120,7 @@ impl Chunk for EcmascriptChunk {
120120
content_type: None,
121121
};
122122

123-
Ok(AssetIdent::new(Value::new(ident)))
123+
Ok(AssetIdent::new(ident))
124124
}
125125

126126
#[turbo_tasks::function]

turbopack/crates/turbopack-ecmascript/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -613,7 +613,7 @@ impl Module for EcmascriptModuleAsset {
613613
}
614614
ident.add_modifier(rcstr!("ecmascript"));
615615
ident.layer = Some(self.asset_context.layer().owned().await?);
616-
Ok(AssetIdent::new(Value::new(ident)))
616+
Ok(AssetIdent::new(ident))
617617
}
618618

619619
#[turbo_tasks::function]

turbopack/crates/turbopack-ecmascript/src/tree_shake/side_effect_module.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use anyhow::Result;
22
use turbo_rcstr::{RcStr, rcstr};
3-
use turbo_tasks::{ResolvedVc, TryJoinIterExt, Value, Vc};
3+
use turbo_tasks::{ResolvedVc, TryJoinIterExt, Vc};
44
use turbo_tasks_fs::glob::Glob;
55
use turbopack_core::{
66
asset::{Asset, AssetContent},
@@ -70,7 +70,7 @@ impl Module for SideEffectsModule {
7070
);
7171
}
7272

73-
Ok(AssetIdent::new(Value::new(ident)))
73+
Ok(AssetIdent::new(ident))
7474
}
7575

7676
#[turbo_tasks::function]

turbopack/crates/turbopack-node/src/transforms/postcss.rs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use indoc::formatdoc;
33
use serde::{Deserialize, Serialize};
44
use turbo_rcstr::{RcStr, rcstr};
55
use turbo_tasks::{
6-
Completion, Completions, NonLocalValue, ResolvedVc, TaskInput, TryFlatJoinIterExt, Value, Vc,
6+
Completion, Completions, NonLocalValue, ResolvedVc, TaskInput, TryFlatJoinIterExt, Vc,
77
fxindexmap, trace::TraceRawVcs,
88
};
99
use turbo_tasks_bytes::stream::SingleValue;
@@ -420,12 +420,9 @@ async fn find_config_in_location(
420420
location: PostCssConfigLocation,
421421
source: Vc<Box<dyn Source>>,
422422
) -> Result<Option<Vc<FileSystemPath>>> {
423-
if let FindContextFileResult::Found(config_path, _) = *find_context_file_or_package_key(
424-
project_path,
425-
postcss_configs(),
426-
Value::new(rcstr!("postcss")),
427-
)
428-
.await?
423+
if let FindContextFileResult::Found(config_path, _) =
424+
*find_context_file_or_package_key(project_path, postcss_configs(), rcstr!("postcss"))
425+
.await?
429426
{
430427
return Ok(Some(*config_path));
431428
}
@@ -434,7 +431,7 @@ async fn find_config_in_location(
434431
&& let FindContextFileResult::Found(config_path, _) = *find_context_file_or_package_key(
435432
source.ident().path().parent(),
436433
postcss_configs(),
437-
Value::new(rcstr!("postcss")),
434+
rcstr!("postcss"),
438435
)
439436
.await?
440437
{

turbopack/crates/turbopack-nodejs/src/chunking_context.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use anyhow::{Context, Result, bail};
22
use tracing::Instrument;
33
use turbo_rcstr::{RcStr, rcstr};
4-
use turbo_tasks::{ResolvedVc, TryJoinIterExt, Upcast, Value, ValueToString, Vc};
4+
use turbo_tasks::{ResolvedVc, TaskInput, TryJoinIterExt, Upcast, ValueToString, Vc};
55
use turbo_tasks_fs::FileSystemPath;
66
use turbopack_core::{
77
asset::Asset,
@@ -91,13 +91,13 @@ impl NodeJsChunkingContextBuilder {
9191

9292
/// Builds the chunking context.
9393
pub fn build(self) -> Vc<NodeJsChunkingContext> {
94-
NodeJsChunkingContext::new(Value::new(self.chunking_context))
94+
NodeJsChunkingContext::new(self.chunking_context)
9595
}
9696
}
9797

9898
/// A chunking context for build mode.
9999
#[turbo_tasks::value(serialization = "auto_for_input")]
100-
#[derive(Debug, Clone, Hash)]
100+
#[derive(Debug, Clone, Hash, TaskInput)]
101101
pub struct NodeJsChunkingContext {
102102
/// The root path of the project
103103
root_path: ResolvedVc<FileSystemPath>,
@@ -192,8 +192,8 @@ impl NodeJsChunkingContext {
192192
#[turbo_tasks::value_impl]
193193
impl NodeJsChunkingContext {
194194
#[turbo_tasks::function]
195-
fn new(this: Value<NodeJsChunkingContext>) -> Vc<Self> {
196-
this.into_value().cell()
195+
fn new(this: NodeJsChunkingContext) -> Vc<Self> {
196+
this.cell()
197197
}
198198

199199
#[turbo_tasks::function]

0 commit comments

Comments
 (0)