Skip to content

Commit fd535fb

Browse files
committed
Turbopack: remove referenced_assets field
1 parent f7cf3e8 commit fd535fb

File tree

25 files changed

+169
-185
lines changed

25 files changed

+169
-185
lines changed

crates/next-api/src/app.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1815,7 +1815,7 @@ impl AppEndpoint {
18151815
.await?;
18161816
}
18171817

1818-
let current_referenced_assets = current_chunk_group.referenced_assets();
1818+
let current_references = current_chunk_group.references();
18191819
let chunk_group = current_chunk_group.await?;
18201820
let current_availability_info = chunk_group.availability_info;
18211821
let current_chunks = chunk_group.assets;
@@ -1832,13 +1832,12 @@ impl AppEndpoint {
18321832
evaluatable_assets,
18331833
module_graph,
18341834
*current_chunks,
1835-
current_referenced_assets,
1835+
current_references,
18361836
current_availability_info,
18371837
)
18381838
.to_resolved()
18391839
.await?,
18401840
]),
1841-
referenced_assets: ResolvedVc::cell(vec![]),
18421841
references: ResolvedVc::cell(vec![]),
18431842
}
18441843
.cell(),

crates/next-api/src/instrumentation.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ use turbopack_core::{
1919
GraphEntries,
2020
chunk_group_info::{ChunkGroup, ChunkGroupEntry},
2121
},
22-
output::{OutputAsset, OutputAssets, OutputAssetsWithReferenced},
22+
output::{OutputAsset, OutputAssets, OutputAssetsReferences, OutputAssetsWithReferenced},
2323
reference_type::{EntryReferenceSubType, ReferenceType},
2424
source::Source,
2525
virtual_output::VirtualOutputAsset,
@@ -133,7 +133,7 @@ impl InstrumentationEndpoint {
133133
Vc::cell(vec![module]),
134134
module_graph,
135135
OutputAssets::empty(),
136-
OutputAssets::empty(),
136+
OutputAssetsReferences::empty(),
137137
AvailabilityInfo::Root,
138138
)
139139
.await?;

crates/next-api/src/middleware.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ use turbopack_core::{
2424
GraphEntries,
2525
chunk_group_info::{ChunkGroup, ChunkGroupEntry},
2626
},
27-
output::{OutputAsset, OutputAssets, OutputAssetsWithReferenced},
27+
output::{OutputAsset, OutputAssets, OutputAssetsReferences, OutputAssetsWithReferenced},
2828
reference_type::{EntryReferenceSubType, ReferenceType},
2929
source::Source,
3030
virtual_output::VirtualOutputAsset,
@@ -146,7 +146,7 @@ impl MiddlewareEndpoint {
146146
Vc::cell(vec![module]),
147147
module_graph,
148148
OutputAssets::empty(),
149-
OutputAssets::empty(),
149+
OutputAssetsReferences::empty(),
150150
AvailabilityInfo::Root,
151151
)
152152
.await?;

crates/next-api/src/pages.rs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ use turbopack_core::{
5656
GraphEntries, ModuleGraph, SingleModuleGraph, VisitedModules,
5757
chunk_group_info::{ChunkGroup, ChunkGroupEntry},
5858
},
59-
output::{OptionOutputAsset, OutputAsset, OutputAssets},
59+
output::{OptionOutputAsset, OutputAsset, OutputAssets, OutputAssetsReferences},
6060
reference::all_assets_from_entries,
6161
reference_type::{EcmaScriptModulesReferenceSubType, EntryReferenceSubType, ReferenceType},
6262
resolve::{origin::PlainResolveOrigin, parse::Request, pattern::Pattern},
@@ -1047,7 +1047,7 @@ impl PageEndpoint {
10471047

10481048
Ok(SsrChunk::Edge {
10491049
assets: chunk_assets.primary_assets().to_resolved().await?,
1050-
referenced_assets: chunk_assets.referenced_assets().to_resolved().await?,
1050+
references: chunk_assets.references().to_resolved().await?,
10511051
dynamic_import_entries,
10521052
regions: regions.clone(),
10531053
}
@@ -1065,7 +1065,7 @@ impl PageEndpoint {
10651065
EvaluatableAssets::empty().with_entry(*ssr_module_evaluatable),
10661066
ssr_module_graph,
10671067
current_chunk_group.primary_assets(),
1068-
current_chunk_group.referenced_assets(),
1068+
current_chunk_group.references(),
10691069
current_chunk_group.await?.availability_info,
10701070
)
10711071
.to_resolved()
@@ -1408,7 +1408,7 @@ impl PageEndpoint {
14081408
}
14091409
SsrChunk::Edge {
14101410
assets,
1411-
referenced_assets,
1411+
references,
14121412
dynamic_import_entries,
14131413
ref regions,
14141414
} => {
@@ -1428,10 +1428,12 @@ impl PageEndpoint {
14281428
fxindexset![]
14291429
};
14301430

1431-
let all_assets = assets.concatenate(*referenced_assets);
1431+
let referenced_assets = references.all_assets();
1432+
1433+
let all_assets = assets.concatenate(referenced_assets);
14321434
let assets_ref = assets.await?;
14331435

1434-
server_assets.extend(referenced_assets.await?.iter().copied());
1436+
server_assets.extend(referenced_assets.await?.into_iter().copied());
14351437

14361438
// TODO(sokra): accessing the 1st asset is a bit hacky, we should find a better
14371439
// way to get the main entry asset
@@ -1771,7 +1773,7 @@ pub enum SsrChunk {
17711773
},
17721774
Edge {
17731775
assets: ResolvedVc<OutputAssets>,
1774-
referenced_assets: ResolvedVc<OutputAssets>,
1776+
references: ResolvedVc<OutputAssetsReferences>,
17751777
dynamic_import_entries: ResolvedVc<DynamicImportedChunks>,
17761778
regions: Option<Vec<RcStr>>,
17771779
},

crates/next-core/src/next_app/app_client_references_chunks.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,6 @@ pub async fn get_app_client_references_chunks(
160160

161161
let mut current_client_chunk_group = ChunkGroupResult {
162162
assets: ResolvedVc::cell(vec![]),
163-
referenced_assets: ResolvedVc::cell(vec![]),
164163
references: ResolvedVc::cell(vec![]),
165164
availability_info: client_availability_info,
166165
}

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

Lines changed: 33 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ use turbopack_core::{
1414
asset::{Asset, AssetContent},
1515
chunk::{ChunkingContext, ModuleChunkItemIdExt, ModuleId as TurbopackModuleId},
1616
module_graph::async_module_info::AsyncModulesInfo,
17-
output::{OutputAsset, OutputAssets, OutputAssetsReference, OutputAssetsWithReferenced},
17+
output::{
18+
OutputAsset, OutputAssetsReference, OutputAssetsReferences, OutputAssetsWithReferenced,
19+
},
1820
};
1921
use turbopack_ecmascript::utils::StringifyJs;
2022

@@ -109,9 +111,13 @@ pub struct ClientReferenceManifest {
109111
impl OutputAssetsReference for ClientReferenceManifest {
110112
#[turbo_tasks::function]
111113
async fn references(self: Vc<Self>) -> Result<Vc<OutputAssetsWithReferenced>> {
112-
Ok(OutputAssetsWithReferenced::from_assets(
113-
*build_manifest(self).await?.references,
114-
))
114+
Ok(OutputAssetsWithReferenced {
115+
assets: ResolvedVc::cell(vec![]),
116+
references: ResolvedVc::cell(vec![ResolvedVc::upcast(
117+
build_manifest(self).await?.references,
118+
)]),
119+
}
120+
.cell())
115121
}
116122
}
117123

@@ -140,7 +146,7 @@ impl Asset for ClientReferenceManifest {
140146
#[turbo_tasks::value(shared)]
141147
struct ClientReferenceManifestResult {
142148
content: ResolvedVc<AssetContent>,
143-
references: ResolvedVc<OutputAssets>,
149+
references: ResolvedVc<OutputAssetsReferences>,
144150
}
145151

146152
#[turbo_tasks::function]
@@ -166,7 +172,7 @@ async fn build_manifest(
166172
);
167173
async move {
168174
let mut entry_manifest: SerializedClientReferenceManifest = Default::default();
169-
let mut references = FxIndexSet::default();
175+
let mut references = Vec::new();
170176
let chunk_suffix_path = next_config.chunk_suffix_path().owned().await?;
171177
let prefix_path = next_config.computed_asset_prefix().owned().await?;
172178
let suffix_path = chunk_suffix_path.unwrap_or_default();
@@ -259,14 +265,17 @@ async fn build_manifest(
259265
let (client_chunks_paths, client_is_async) = if let Some(client_assets) =
260266
client_component_client_chunks.get(&app_client_reference_ty)
261267
{
262-
let client_chunks = client_assets.primary_assets().await?;
263-
let client_referenced_assets = client_assets.referenced_assets().await?;
264-
references.extend(client_chunks.iter());
265-
references.extend(client_referenced_assets.iter());
266-
267-
let client_chunks_paths =
268-
cached_chunk_paths(&mut client_chunk_path_cache, client_chunks.iter().copied())
269-
.await?;
268+
let client_chunks = client_assets.primary_assets().to_resolved().await?;
269+
references.push(ResolvedVc::upcast(client_chunks));
270+
references.push(ResolvedVc::upcast(
271+
client_assets.references().to_resolved().await?,
272+
));
273+
274+
let client_chunks_paths = cached_chunk_paths(
275+
&mut client_chunk_path_cache,
276+
client_chunks.await?.into_iter().copied(),
277+
)
278+
.await?;
270279

271280
let chunk_paths = client_chunks_paths
272281
.filter_map(|(_, chunk_path)| {
@@ -312,14 +321,16 @@ async fn build_manifest(
312321
} else if let Some(ssr_assets) =
313322
client_component_ssr_chunks.get(&app_client_reference_ty)
314323
{
315-
let ssr_chunks = ssr_assets.primary_assets().await?;
316-
let ssr_referenced_assets = ssr_assets.referenced_assets().await?;
317-
references.extend(ssr_chunks.iter());
318-
references.extend(ssr_referenced_assets.iter());
319-
320-
let ssr_chunks_paths =
321-
cached_chunk_paths(&mut ssr_chunk_path_cache, ssr_chunks.iter().copied())
322-
.await?;
324+
let ssr_chunks = ssr_assets.primary_assets().to_resolved().await?;
325+
let ssr_referenced_assets = ssr_assets.references().to_resolved().await?;
326+
references.push(ResolvedVc::upcast(ssr_chunks));
327+
references.push(ResolvedVc::upcast(ssr_referenced_assets));
328+
329+
let ssr_chunks_paths = cached_chunk_paths(
330+
&mut ssr_chunk_path_cache,
331+
ssr_chunks.await?.into_iter().copied(),
332+
)
333+
.await?;
323334
let chunk_paths = ssr_chunks_paths
324335
.filter_map(|(_, chunk_path)| {
325336
node_root_ref

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

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ use turbopack_core::{
2626
chunk_group_info::ChunkGroup,
2727
export_usage::{ExportUsageInfo, ModuleExportUsage},
2828
},
29-
output::{OutputAsset, OutputAssets},
29+
output::{OutputAsset, OutputAssets, OutputAssetsReferences},
3030
};
3131
use turbopack_ecmascript::{
3232
async_chunk::module::AsyncLoaderModule,
@@ -662,7 +662,7 @@ impl ChunkingContext for BrowserChunkingContext {
662662
let MakeChunkGroupResult {
663663
chunks,
664664
referenced_output_assets,
665-
references,
665+
mut references,
666666
availability_info,
667667
} = make_chunk_group(
668668
entries,
@@ -678,6 +678,10 @@ impl ChunkingContext for BrowserChunkingContext {
678678
.try_join()
679679
.await?;
680680

681+
let referenced_output_assets: ResolvedVc<OutputAssets> =
682+
ResolvedVc::cell(referenced_output_assets);
683+
references.push(ResolvedVc::upcast(referenced_output_assets));
684+
681685
if this.enable_hot_module_replacement {
682686
let mut ident = ident;
683687
match input_availability_info {
@@ -705,7 +709,6 @@ impl ChunkingContext for BrowserChunkingContext {
705709

706710
Ok(ChunkGroupResult {
707711
assets: ResolvedVc::cell(assets),
708-
referenced_assets: ResolvedVc::cell(referenced_output_assets),
709712
references: ResolvedVc::cell(references),
710713
availability_info,
711714
}
@@ -734,7 +737,7 @@ impl ChunkingContext for BrowserChunkingContext {
734737
let MakeChunkGroupResult {
735738
chunks,
736739
referenced_output_assets,
737-
references,
740+
mut references,
738741
availability_info,
739742
} = make_chunk_group(
740743
entries,
@@ -750,6 +753,10 @@ impl ChunkingContext for BrowserChunkingContext {
750753
.try_join()
751754
.await?;
752755

756+
let referenced_output_assets: ResolvedVc<OutputAssets> =
757+
ResolvedVc::cell(referenced_output_assets);
758+
references.push(ResolvedVc::upcast(referenced_output_assets));
759+
753760
let other_assets = Vc::cell(assets.clone());
754761

755762
let entries = Vc::cell(
@@ -794,7 +801,6 @@ impl ChunkingContext for BrowserChunkingContext {
794801

795802
Ok(ChunkGroupResult {
796803
assets: ResolvedVc::cell(assets),
797-
referenced_assets: ResolvedVc::cell(referenced_output_assets),
798804
references: ResolvedVc::cell(references),
799805
availability_info,
800806
}
@@ -811,7 +817,7 @@ impl ChunkingContext for BrowserChunkingContext {
811817
_evaluatable_assets: Vc<EvaluatableAssets>,
812818
_module_graph: Vc<ModuleGraph>,
813819
_extra_chunks: Vc<OutputAssets>,
814-
_extra_referenced_assets: Vc<OutputAssets>,
820+
_extra_references: Vc<OutputAssetsReferences>,
815821
_availability_info: AvailabilityInfo,
816822
) -> Result<Vc<EntryChunkGroupResult>> {
817823
bail!("Browser chunking context does not support entry chunk groups")

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,6 @@ impl OutputAssetsReference for EcmascriptBrowserChunk {
117117

118118
Ok(OutputAssetsWithReferenced {
119119
assets: ResolvedVc::cell(assets),
120-
referenced_assets: chunk_references.referenced_assets,
121120
references: chunk_references.references,
122121
}
123122
.cell())

turbopack/crates/turbopack-cli/src/build/mod.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ use turbopack_core::{
3636
chunk_group_info::{ChunkGroup, ChunkGroupEntry},
3737
export_usage::compute_export_usage_info,
3838
},
39-
output::{OutputAsset, OutputAssets, OutputAssetsWithReferenced},
39+
output::{OutputAsset, OutputAssets, OutputAssetsReferences, OutputAssetsWithReferenced},
4040
reference_type::{EntryReferenceSubType, ReferenceType},
4141
resolve::{
4242
origin::{PlainResolveOrigin, ResolveOriginExt},
@@ -463,13 +463,12 @@ async fn build_internal(
463463
EvaluatableAssets::one(*ecmascript),
464464
module_graph,
465465
OutputAssets::empty(),
466-
OutputAssets::empty(),
466+
OutputAssetsReferences::empty(),
467467
AvailabilityInfo::Root,
468468
)
469469
.await?
470470
.asset,
471471
]),
472-
referenced_assets: ResolvedVc::cell(vec![]),
473472
references: ResolvedVc::cell(vec![]),
474473
}
475474
.cell(),

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,7 @@ use crate::{
2626
module_batches::{BatchingConfig, ModuleBatchesGraphEdge},
2727
},
2828
output::{
29-
OutputAsset, OutputAssets, OutputAssetsReference, OutputAssetsReferences,
30-
OutputAssetsWithReferenced,
29+
OutputAsset, OutputAssetsReference, OutputAssetsReferences, OutputAssetsWithReferenced,
3130
},
3231
reference::ModuleReference,
3332
traced_asset::TracedAsset,
@@ -174,7 +173,6 @@ pub async fn references_to_output_assets(
174173
.collect::<Vec<_>>();
175174
Ok(OutputAssetsWithReferenced {
176175
assets: ResolvedVc::cell(output_assets),
177-
referenced_assets: OutputAssets::empty_resolved(),
178176
references: OutputAssetsReferences::empty_resolved(),
179177
}
180178
.cell())

0 commit comments

Comments
 (0)