Skip to content

Commit a276676

Browse files
committed
Remove uses of Value<..> instead make the payload a Taskinput
1 parent 3d1657f commit a276676

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>,
@@ -118,7 +118,7 @@ impl ValueToString for AssetIdent {
118118
#[turbo_tasks::value_impl]
119119
impl AssetIdent {
120120
#[turbo_tasks::function]
121-
pub async fn new(ident: Value<AssetIdent>) -> Result<Vc<Self>> {
121+
pub async fn new(ident: AssetIdent) -> Result<Vc<Self>> {
122122
debug_assert!(
123123
ident.query.is_empty() || ident.query.starts_with("?"),
124124
"query should be empty or start with a `?`"
@@ -127,13 +127,13 @@ impl AssetIdent {
127127
ident.fragment.is_empty() || ident.fragment.starts_with("#"),
128128
"query should be empty or start with a `?`"
129129
);
130-
Ok(ident.into_value().cell())
130+
Ok(ident.cell())
131131
}
132132

133133
/// Creates an [AssetIdent] from a [Vc<FileSystemPath>]
134134
#[turbo_tasks::function]
135135
pub fn from_path(path: ResolvedVc<FileSystemPath>) -> Vc<Self> {
136-
Self::new(Value::new(AssetIdent {
136+
Self::new(AssetIdent {
137137
path,
138138
query: RcStr::default(),
139139
fragment: RcStr::default(),
@@ -142,63 +142,63 @@ impl AssetIdent {
142142
parts: Vec::new(),
143143
layer: None,
144144
content_type: None,
145-
}))
145+
})
146146
}
147147

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

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

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

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

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

183183
#[turbo_tasks::function]
184184
pub fn with_layer(&self, layer: RcStr) -> Vc<Self> {
185185
let mut this = self.clone();
186186
this.layer = Some(layer);
187-
Self::new(Value::new(this))
187+
Self::new(this)
188188
}
189189

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

197197
#[turbo_tasks::function]
198198
pub async fn rename_as(&self, pattern: RcStr) -> Result<Vc<Self>> {
199199
let mut this = self.clone();
200200
this.rename_as_ref(&pattern).await?;
201-
Ok(Self::new(Value::new(this)))
201+
Ok(Self::new(this))
202202
}
203203

204204
#[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
if let Some(json) = &*read_package_json(*package_json_path).await? {
1332-
if json.get(&**package_key).is_some() {
1337+
if json.get(&*package_key).is_some() {
13331338
return Ok(FindContextFileResult::Found(package_json_path, refs).into());
13341339
}
13351340
}
@@ -2445,7 +2450,7 @@ async fn apply_in_package(
24452450
.with_fragment(fragment.clone()),
24462451
options,
24472452
)
2448-
.with_replaced_request_key(value.into(), Value::new(request_key))
2453+
.with_replaced_request_key(value.into(), request_key)
24492454
.with_affecting_sources(refs.into_iter().map(|src| *src).collect()),
24502455
));
24512456
}
@@ -2604,7 +2609,7 @@ async fn resolve_module_request(
26042609

26052610
let module_result =
26062611
merge_results_with_affecting_sources(results, result.affecting_sources.clone())
2607-
.with_replaced_request_key(rcstr!("."), Value::new(RequestKey::new(module.into())));
2612+
.with_replaced_request_key(rcstr!("."), RequestKey::new(module.into()));
26082613

26092614
if options_value.prefer_relative {
26102615
let module_prefix: RcStr = format!("./{module}").into();
@@ -2619,7 +2624,7 @@ async fn resolve_module_request(
26192624
let relative_result =
26202625
Box::pin(resolve_internal_inline(lookup_path, *relative, options)).await?;
26212626
let relative_result = relative_result
2622-
.with_replaced_request_key(module_prefix, Value::new(RequestKey::new(module.into())));
2627+
.with_replaced_request_key(module_prefix, RequestKey::new(module.into()));
26232628

26242629
Ok(merge_results(vec![relative_result, module_result]))
26252630
} 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
if 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)