Skip to content

Commit ab9b856

Browse files
committed
chore(turbopack): Make TaskInputs use ResolvedVc
1 parent 74b2f52 commit ab9b856

File tree

5 files changed

+106
-93
lines changed

5 files changed

+106
-93
lines changed

crates/next-api/src/app.rs

+43-36
Original file line numberDiff line numberDiff line change
@@ -1150,10 +1150,8 @@ impl AppEndpoint {
11501150
),
11511151
};
11521152

1153-
let node_root = project.node_root();
1154-
1155-
let client_relative_path = project.client_relative_path();
1156-
1153+
let node_root = project.node_root().to_resolved().await?;
1154+
let client_relative_path = project.client_relative_path().to_resolved().await?;
11571155
let server_path = node_root.join("server".into());
11581156

11591157
let mut server_assets = fxindexset![];
@@ -1174,16 +1172,20 @@ impl AppEndpoint {
11741172
)
11751173
.await?;
11761174

1177-
let client_chunking_context = project.client_chunking_context();
1175+
let client_chunking_context = project.client_chunking_context().to_resolved().await?;
11781176

11791177
let ssr_chunking_context = if process_ssr {
1180-
Some(match runtime {
1181-
NextRuntime::NodeJs => Vc::upcast(project.server_chunking_context(true)),
1182-
NextRuntime::Edge => this
1183-
.app_project
1184-
.project()
1185-
.edge_chunking_context(process_client_assets),
1186-
})
1178+
Some(
1179+
match runtime {
1180+
NextRuntime::NodeJs => Vc::upcast(project.server_chunking_context(true)),
1181+
NextRuntime::Edge => this
1182+
.app_project
1183+
.project()
1184+
.edge_chunking_context(process_client_assets),
1185+
}
1186+
.to_resolved()
1187+
.await?,
1188+
)
11871189
} else {
11881190
None
11891191
};
@@ -1193,7 +1195,7 @@ impl AppEndpoint {
11931195
.with_modifier(client_shared_chunks_modifier()),
11941196
this.app_project.client_runtime_entries(),
11951197
*module_graphs.full,
1196-
client_chunking_context,
1198+
*client_chunking_context,
11971199
)
11981200
.await?;
11991201

@@ -1216,18 +1218,23 @@ impl AppEndpoint {
12161218
.get_next_dynamic_imports_for_endpoint(*rsc_entry)
12171219
.await?;
12181220

1219-
let client_references = reduced_graphs.get_client_references_for_endpoint(
1220-
*rsc_entry,
1221-
matches!(this.ty, AppEndpointType::Page { .. }),
1222-
);
1221+
let client_references = reduced_graphs
1222+
.get_client_references_for_endpoint(
1223+
*rsc_entry,
1224+
matches!(this.ty, AppEndpointType::Page { .. }),
1225+
)
1226+
.to_resolved()
1227+
.await?;
12231228

12241229
let client_references_chunks = get_app_client_references_chunks(
1225-
client_references,
1230+
*client_references,
12261231
*module_graphs.full,
1227-
client_chunking_context,
1232+
*client_chunking_context,
12281233
Value::new(client_shared_availability_info),
1229-
ssr_chunking_context,
1230-
);
1234+
ssr_chunking_context.map(|ctx| *ctx),
1235+
)
1236+
.to_resolved()
1237+
.await?;
12311238
let client_references_chunks_ref = client_references_chunks.await?;
12321239

12331240
let mut entry_client_chunks = FxIndexSet::default();
@@ -1272,7 +1279,7 @@ impl AppEndpoint {
12721279
node_root.join(
12731280
format!("server/app{manifest_path_prefix}/app-build-manifest.json",).into(),
12741281
),
1275-
client_relative_path,
1282+
*client_relative_path,
12761283
)
12771284
.await?
12781285
.to_resolved()
@@ -1328,7 +1335,7 @@ impl AppEndpoint {
13281335
node_root.join(
13291336
format!("server/app{manifest_path_prefix}/build-manifest.json",).into(),
13301337
),
1331-
client_relative_path,
1338+
*client_relative_path,
13321339
)
13331340
.await?
13341341
.to_resolved()
@@ -1363,7 +1370,7 @@ impl AppEndpoint {
13631370
let server_action_manifest = create_server_actions_manifest(
13641371
actions,
13651372
project.project_path(),
1366-
node_root,
1373+
*node_root,
13671374
app_entry.original_name.clone(),
13681375
runtime,
13691376
match runtime {
@@ -1384,7 +1391,7 @@ impl AppEndpoint {
13841391

13851392
let app_entry_chunks = self
13861393
.app_entry_chunks(
1387-
client_references,
1394+
*client_references,
13881395
*server_action_manifest_loader,
13891396
server_path,
13901397
process_client_assets,
@@ -1410,13 +1417,13 @@ impl AppEndpoint {
14101417
entry_name: app_entry.original_name.clone(),
14111418
client_references,
14121419
client_references_chunks,
1413-
rsc_app_entry_chunks: *app_entry_chunks,
1420+
rsc_app_entry_chunks: app_entry_chunks,
14141421
client_chunking_context,
14151422
ssr_chunking_context,
1416-
async_module_info: module_graphs.full.async_module_info(),
1417-
next_config: project.next_config(),
1423+
async_module_info: module_graphs.full.async_module_info().to_resolved().await?,
1424+
next_config: project.next_config().to_resolved().await?,
14181425
runtime,
1419-
mode: project.next_mode(),
1426+
mode: *project.next_mode().await?,
14201427
})
14211428
.to_resolved()
14221429
.await?;
@@ -1428,7 +1435,7 @@ impl AppEndpoint {
14281435

14291436
let next_font_manifest_output = create_font_manifest(
14301437
project.client_root(),
1431-
node_root,
1438+
*node_root,
14321439
this.app_project.app_dir(),
14331440
&app_entry.original_name,
14341441
&app_entry.original_name,
@@ -1476,7 +1483,7 @@ impl AppEndpoint {
14761483
if emit_manifests == EmitManifests::Full {
14771484
let dynamic_import_entries = collect_next_dynamic_chunks(
14781485
*module_graphs.full,
1479-
Vc::upcast(client_chunking_context),
1486+
*ResolvedVc::upcast(client_chunking_context),
14801487
next_dynamic_imports,
14811488
NextDynamicChunkAvailability::ClientReferences(
14821489
&*(client_references_chunks.await?),
@@ -1486,7 +1493,7 @@ impl AppEndpoint {
14861493

14871494
let loadable_manifest_output = create_react_loadable_manifest(
14881495
*dynamic_import_entries,
1489-
client_relative_path,
1496+
*client_relative_path,
14901497
node_root.join(
14911498
format!(
14921499
"server/app{}/react-loadable-manifest",
@@ -1556,7 +1563,7 @@ impl AppEndpoint {
15561563
if emit_manifests != EmitManifests::None {
15571564
// create app paths manifest
15581565
let app_paths_manifest_output =
1559-
create_app_paths_manifest(node_root, &app_entry.original_name, entry_file)
1566+
create_app_paths_manifest(*node_root, &app_entry.original_name, entry_file)
15601567
.await?;
15611568
server_assets.insert(app_paths_manifest_output);
15621569
}
@@ -1576,7 +1583,7 @@ impl AppEndpoint {
15761583
if emit_manifests != EmitManifests::None {
15771584
// create app paths manifest
15781585
let app_paths_manifest_output = create_app_paths_manifest(
1579-
node_root,
1586+
*node_root,
15801587
&app_entry.original_name,
15811588
server_path
15821589
.await?
@@ -1594,7 +1601,7 @@ impl AppEndpoint {
15941601
// create react-loadable-manifest for next/dynamic
15951602
let dynamic_import_entries = collect_next_dynamic_chunks(
15961603
*module_graphs.full,
1597-
Vc::upcast(client_chunking_context),
1604+
*ResolvedVc::upcast(client_chunking_context),
15981605
next_dynamic_imports,
15991606
NextDynamicChunkAvailability::ClientReferences(
16001607
&*(client_references_chunks.await?),
@@ -1604,7 +1611,7 @@ impl AppEndpoint {
16041611

16051612
let loadable_manifest_output = create_react_loadable_manifest(
16061613
*dynamic_import_entries,
1607-
client_relative_path,
1614+
*client_relative_path,
16081615
node_root.join(
16091616
format!(
16101617
"server/app{}/react-loadable-manifest",

crates/next-core/src/next_manifests/client_reference_manifest.rs

+14-14
Original file line numberDiff line numberDiff line change
@@ -32,18 +32,18 @@ use crate::{
3232

3333
#[derive(TaskInput, Clone, Hash, Debug, PartialEq, Eq, Serialize, Deserialize, TraceRawVcs)]
3434
pub struct ClientReferenceManifestOptions {
35-
pub node_root: Vc<FileSystemPath>,
36-
pub client_relative_path: Vc<FileSystemPath>,
35+
pub node_root: ResolvedVc<FileSystemPath>,
36+
pub client_relative_path: ResolvedVc<FileSystemPath>,
3737
pub entry_name: RcStr,
38-
pub client_references: Vc<ClientReferenceGraphResult>,
39-
pub client_references_chunks: Vc<ClientReferencesChunks>,
40-
pub rsc_app_entry_chunks: Vc<OutputAssets>,
41-
pub client_chunking_context: Vc<Box<dyn ChunkingContext>>,
42-
pub ssr_chunking_context: Option<Vc<Box<dyn ChunkingContext>>>,
43-
pub async_module_info: Vc<AsyncModulesInfo>,
44-
pub next_config: Vc<NextConfig>,
38+
pub client_references: ResolvedVc<ClientReferenceGraphResult>,
39+
pub client_references_chunks: ResolvedVc<ClientReferencesChunks>,
40+
pub rsc_app_entry_chunks: ResolvedVc<OutputAssets>,
41+
pub client_chunking_context: ResolvedVc<Box<dyn ChunkingContext>>,
42+
pub ssr_chunking_context: Option<ResolvedVc<Box<dyn ChunkingContext>>>,
43+
pub async_module_info: ResolvedVc<AsyncModulesInfo>,
44+
pub next_config: ResolvedVc<NextConfig>,
4545
pub runtime: NextRuntime,
46-
pub mode: Vc<NextMode>,
46+
pub mode: NextMode,
4747
}
4848

4949
#[turbo_tasks::value_impl]
@@ -181,7 +181,7 @@ impl ClientReferenceManifest {
181181
let server_path = client_reference_module_ref.server_ident.to_string().await?;
182182
let client_module = client_reference_module_ref.client_module;
183183
let client_chunk_item_id = client_module
184-
.chunk_item_id(Vc::upcast(client_chunking_context))
184+
.chunk_item_id(*ResolvedVc::upcast(client_chunking_context))
185185
.await?;
186186

187187
let (client_chunks_paths, client_is_async) =
@@ -226,11 +226,11 @@ impl ClientReferenceManifest {
226226
if let Some(ssr_chunking_context) = ssr_chunking_context {
227227
let ssr_module = client_reference_module_ref.ssr_module;
228228
let ssr_chunk_item_id = ssr_module
229-
.chunk_item_id(Vc::upcast(ssr_chunking_context))
229+
.chunk_item_id(*ResolvedVc::upcast(ssr_chunking_context))
230230
.await?;
231231

232232
let rsc_chunk_item_id = client_reference_module
233-
.chunk_item_id(Vc::upcast(ssr_chunking_context))
233+
.chunk_item_id(*ResolvedVc::upcast(ssr_chunking_context))
234234
.await?;
235235

236236
let (ssr_chunks_paths, ssr_is_async) = if runtime == NextRuntime::Edge {
@@ -385,7 +385,7 @@ impl ClientReferenceManifest {
385385
}
386386

387387
let inlined = next_config.await?.experimental.inline_css.unwrap_or(false)
388-
&& mode.await?.is_production();
388+
&& mode.is_production();
389389
let entry_css_files_vec = entry_css_files_with_chunk
390390
.into_iter()
391391
.map(async |(path, chunk)| {

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

+27-23
Original file line numberDiff line numberDiff line change
@@ -413,9 +413,9 @@ impl EcmascriptAnalyzable for EcmascriptModuleAsset {
413413
#[turbo_tasks::function]
414414
async fn module_content(
415415
self: Vc<Self>,
416-
module_graph: Vc<ModuleGraph>,
417-
chunking_context: Vc<Box<dyn ChunkingContext>>,
418-
async_module_info: Option<Vc<AsyncModuleInfo>>,
416+
module_graph: ResolvedVc<ModuleGraph>,
417+
chunking_context: ResolvedVc<Box<dyn ChunkingContext>>,
418+
async_module_info: Option<ResolvedVc<AsyncModuleInfo>>,
419419
) -> Result<Vc<EcmascriptModuleContent>> {
420420
let parsed = self.parse().to_resolved().await?;
421421

@@ -430,17 +430,17 @@ impl EcmascriptAnalyzable for EcmascriptModuleAsset {
430430
Ok(EcmascriptModuleContent::new(
431431
EcmascriptModuleContentOptions {
432432
parsed,
433-
ident: self.ident(),
433+
ident: self.ident().to_resolved().await?,
434434
specified_module_type: module_type_result.module_type,
435435
module_graph,
436436
chunking_context,
437-
references: analyze.references(),
438-
esm_references: *analyze_ref.esm_references,
439-
code_generation: *analyze_ref.code_generation,
440-
async_module: *analyze_ref.async_module,
437+
references: analyze.references().to_resolved().await?,
438+
esm_references: analyze_ref.esm_references,
439+
code_generation: analyze_ref.code_generation,
440+
async_module: analyze_ref.async_module,
441441
generate_source_map,
442442
original_source_map: analyze_ref.source_map,
443-
exports: *analyze_ref.exports,
443+
exports: analyze_ref.exports,
444444
async_module_info,
445445
},
446446
))
@@ -775,18 +775,18 @@ pub struct EcmascriptModuleContent {
775775
#[derive(Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize, TaskInput, TraceRawVcs)]
776776
pub struct EcmascriptModuleContentOptions {
777777
parsed: ResolvedVc<ParseResult>,
778-
ident: Vc<AssetIdent>,
778+
ident: ResolvedVc<AssetIdent>,
779779
specified_module_type: SpecifiedModuleType,
780-
module_graph: Vc<ModuleGraph>,
781-
chunking_context: Vc<Box<dyn ChunkingContext>>,
782-
references: Vc<ModuleReferences>,
783-
esm_references: Vc<EsmAssetReferences>,
784-
code_generation: Vc<CodeGens>,
785-
async_module: Vc<OptionAsyncModule>,
780+
module_graph: ResolvedVc<ModuleGraph>,
781+
chunking_context: ResolvedVc<Box<dyn ChunkingContext>>,
782+
references: ResolvedVc<ModuleReferences>,
783+
esm_references: ResolvedVc<EsmAssetReferences>,
784+
code_generation: ResolvedVc<CodeGens>,
785+
async_module: ResolvedVc<OptionAsyncModule>,
786786
generate_source_map: bool,
787787
original_source_map: ResolvedVc<OptionStringifiedSourceMap>,
788-
exports: Vc<EcmascriptExports>,
789-
async_module_info: Option<Vc<AsyncModuleInfo>>,
788+
exports: ResolvedVc<EcmascriptExports>,
789+
async_module_info: Option<ResolvedVc<AsyncModuleInfo>>,
790790
}
791791

792792
#[turbo_tasks::value_impl]
@@ -815,7 +815,11 @@ impl EcmascriptModuleContent {
815815
if let Some(async_module) = &*async_module.await? {
816816
Some(
817817
async_module
818-
.code_generation(async_module_info, references, chunking_context)
818+
.code_generation(
819+
async_module_info.map(|info| *info),
820+
*references,
821+
*chunking_context,
822+
)
819823
.await?,
820824
)
821825
} else {
@@ -824,7 +828,7 @@ impl EcmascriptModuleContent {
824828
if let EcmascriptExports::EsmExports(exports) = *exports.await? {
825829
Some(
826830
exports
827-
.code_generation(module_graph, chunking_context, *parsed)
831+
.code_generation(*module_graph, *chunking_context, *parsed)
828832
.await?,
829833
)
830834
} else {
@@ -835,13 +839,13 @@ impl EcmascriptModuleContent {
835839
let esm_code_gens = esm_references
836840
.await?
837841
.iter()
838-
.map(|r| r.code_generation(chunking_context))
842+
.map(|r| r.code_generation(*chunking_context))
839843
.try_join()
840844
.await?;
841845
let code_gens = code_generation
842846
.await?
843847
.iter()
844-
.map(|c| c.code_generation(module_graph, chunking_context))
848+
.map(|c| c.code_generation(*module_graph, *chunking_context))
845849
.try_join()
846850
.await?;
847851

@@ -857,7 +861,7 @@ impl EcmascriptModuleContent {
857861

858862
gen_content_with_code_gens(
859863
parsed,
860-
ident,
864+
*ident,
861865
specified_module_type,
862866
code_gens,
863867
generate_source_map,

0 commit comments

Comments
 (0)