Commit bf865e24 authored by Tobias Koppers's avatar Tobias Koppers

Turbopack: remove referenced_assets field

parent b3b97bc4
...@@ -1816,7 +1816,7 @@ impl AppEndpoint { ...@@ -1816,7 +1816,7 @@ impl AppEndpoint {
.await?; .await?;
} }
let current_referenced_assets = current_chunk_group.referenced_assets(); let current_references = current_chunk_group.references();
let chunk_group = current_chunk_group.await?; let chunk_group = current_chunk_group.await?;
let current_availability_info = chunk_group.availability_info; let current_availability_info = chunk_group.availability_info;
let current_chunks = chunk_group.assets; let current_chunks = chunk_group.assets;
...@@ -1833,13 +1833,12 @@ impl AppEndpoint { ...@@ -1833,13 +1833,12 @@ impl AppEndpoint {
evaluatable_assets, evaluatable_assets,
module_graph, module_graph,
*current_chunks, *current_chunks,
current_referenced_assets, current_references,
current_availability_info, current_availability_info,
) )
.to_resolved() .to_resolved()
.await?, .await?,
]), ]),
referenced_assets: ResolvedVc::cell(vec![]),
references: ResolvedVc::cell(vec![]), references: ResolvedVc::cell(vec![]),
} }
.cell(), .cell(),
......
...@@ -19,7 +19,7 @@ use turbopack_core::{ ...@@ -19,7 +19,7 @@ use turbopack_core::{
GraphEntries, GraphEntries,
chunk_group_info::{ChunkGroup, ChunkGroupEntry}, chunk_group_info::{ChunkGroup, ChunkGroupEntry},
}, },
output::{OutputAsset, OutputAssets, OutputAssetsWithReferenced}, output::{OutputAsset, OutputAssets, OutputAssetsReferences, OutputAssetsWithReferenced},
reference_type::{EntryReferenceSubType, ReferenceType}, reference_type::{EntryReferenceSubType, ReferenceType},
source::Source, source::Source,
virtual_output::VirtualOutputAsset, virtual_output::VirtualOutputAsset,
...@@ -133,7 +133,7 @@ impl InstrumentationEndpoint { ...@@ -133,7 +133,7 @@ impl InstrumentationEndpoint {
Vc::cell(vec![module]), Vc::cell(vec![module]),
module_graph, module_graph,
OutputAssets::empty(), OutputAssets::empty(),
OutputAssets::empty(), OutputAssetsReferences::empty(),
AvailabilityInfo::root(), AvailabilityInfo::root(),
) )
.await?; .await?;
......
...@@ -24,7 +24,7 @@ use turbopack_core::{ ...@@ -24,7 +24,7 @@ use turbopack_core::{
GraphEntries, GraphEntries,
chunk_group_info::{ChunkGroup, ChunkGroupEntry}, chunk_group_info::{ChunkGroup, ChunkGroupEntry},
}, },
output::{OutputAsset, OutputAssets, OutputAssetsWithReferenced}, output::{OutputAsset, OutputAssets, OutputAssetsReferences, OutputAssetsWithReferenced},
reference_type::{EntryReferenceSubType, ReferenceType}, reference_type::{EntryReferenceSubType, ReferenceType},
source::Source, source::Source,
virtual_output::VirtualOutputAsset, virtual_output::VirtualOutputAsset,
...@@ -146,7 +146,7 @@ impl MiddlewareEndpoint { ...@@ -146,7 +146,7 @@ impl MiddlewareEndpoint {
Vc::cell(vec![module]), Vc::cell(vec![module]),
module_graph, module_graph,
OutputAssets::empty(), OutputAssets::empty(),
OutputAssets::empty(), OutputAssetsReferences::empty(),
AvailabilityInfo::root(), AvailabilityInfo::root(),
) )
.await?; .await?;
......
...@@ -56,7 +56,7 @@ use turbopack_core::{ ...@@ -56,7 +56,7 @@ use turbopack_core::{
GraphEntries, ModuleGraph, SingleModuleGraph, VisitedModules, GraphEntries, ModuleGraph, SingleModuleGraph, VisitedModules,
chunk_group_info::{ChunkGroup, ChunkGroupEntry}, chunk_group_info::{ChunkGroup, ChunkGroupEntry},
}, },
output::{OptionOutputAsset, OutputAsset, OutputAssets}, output::{OptionOutputAsset, OutputAsset, OutputAssets, OutputAssetsReferences},
reference::all_assets_from_entries, reference::all_assets_from_entries,
reference_type::{EcmaScriptModulesReferenceSubType, EntryReferenceSubType, ReferenceType}, reference_type::{EcmaScriptModulesReferenceSubType, EntryReferenceSubType, ReferenceType},
resolve::{origin::PlainResolveOrigin, parse::Request, pattern::Pattern}, resolve::{origin::PlainResolveOrigin, parse::Request, pattern::Pattern},
...@@ -1048,7 +1048,7 @@ impl PageEndpoint { ...@@ -1048,7 +1048,7 @@ impl PageEndpoint {
Ok(SsrChunk::Edge { Ok(SsrChunk::Edge {
assets: chunk_assets.primary_assets().to_resolved().await?, assets: chunk_assets.primary_assets().to_resolved().await?,
referenced_assets: chunk_assets.referenced_assets().to_resolved().await?, references: chunk_assets.references().to_resolved().await?,
dynamic_import_entries, dynamic_import_entries,
regions: regions.clone(), regions: regions.clone(),
} }
...@@ -1066,7 +1066,7 @@ impl PageEndpoint { ...@@ -1066,7 +1066,7 @@ impl PageEndpoint {
EvaluatableAssets::empty().with_entry(*ssr_module_evaluatable), EvaluatableAssets::empty().with_entry(*ssr_module_evaluatable),
ssr_module_graph, ssr_module_graph,
current_chunk_group.primary_assets(), current_chunk_group.primary_assets(),
current_chunk_group.referenced_assets(), current_chunk_group.references(),
current_chunk_group.await?.availability_info, current_chunk_group.await?.availability_info,
) )
.to_resolved() .to_resolved()
...@@ -1409,7 +1409,7 @@ impl PageEndpoint { ...@@ -1409,7 +1409,7 @@ impl PageEndpoint {
} }
SsrChunk::Edge { SsrChunk::Edge {
assets, assets,
referenced_assets, references,
dynamic_import_entries, dynamic_import_entries,
ref regions, ref regions,
} => { } => {
...@@ -1429,10 +1429,12 @@ impl PageEndpoint { ...@@ -1429,10 +1429,12 @@ impl PageEndpoint {
fxindexset![] fxindexset![]
}; };
let all_assets = assets.concatenate(*referenced_assets); let referenced_assets = references.all_assets();
let all_assets = assets.concatenate(referenced_assets);
let assets_ref = assets.await?; let assets_ref = assets.await?;
server_assets.extend(referenced_assets.await?.iter().copied()); server_assets.extend(referenced_assets.await?.into_iter().copied());
// TODO(sokra): accessing the 1st asset is a bit hacky, we should find a better // TODO(sokra): accessing the 1st asset is a bit hacky, we should find a better
// way to get the main entry asset // way to get the main entry asset
...@@ -1772,7 +1774,7 @@ pub enum SsrChunk { ...@@ -1772,7 +1774,7 @@ pub enum SsrChunk {
}, },
Edge { Edge {
assets: ResolvedVc<OutputAssets>, assets: ResolvedVc<OutputAssets>,
referenced_assets: ResolvedVc<OutputAssets>, references: ResolvedVc<OutputAssetsReferences>,
dynamic_import_entries: ResolvedVc<DynamicImportedChunks>, dynamic_import_entries: ResolvedVc<DynamicImportedChunks>,
regions: Option<Vec<RcStr>>, regions: Option<Vec<RcStr>>,
}, },
......
...@@ -160,7 +160,6 @@ pub async fn get_app_client_references_chunks( ...@@ -160,7 +160,6 @@ pub async fn get_app_client_references_chunks(
let mut current_client_chunk_group = ChunkGroupResult { let mut current_client_chunk_group = ChunkGroupResult {
assets: ResolvedVc::cell(vec![]), assets: ResolvedVc::cell(vec![]),
referenced_assets: ResolvedVc::cell(vec![]),
references: ResolvedVc::cell(vec![]), references: ResolvedVc::cell(vec![]),
availability_info: client_availability_info, availability_info: client_availability_info,
} }
......
...@@ -14,7 +14,9 @@ use turbopack_core::{ ...@@ -14,7 +14,9 @@ use turbopack_core::{
asset::{Asset, AssetContent}, asset::{Asset, AssetContent},
chunk::{ChunkingContext, ModuleChunkItemIdExt, ModuleId as TurbopackModuleId}, chunk::{ChunkingContext, ModuleChunkItemIdExt, ModuleId as TurbopackModuleId},
module_graph::async_module_info::AsyncModulesInfo, module_graph::async_module_info::AsyncModulesInfo,
output::{OutputAsset, OutputAssets, OutputAssetsReference, OutputAssetsWithReferenced}, output::{
OutputAsset, OutputAssetsReference, OutputAssetsReferences, OutputAssetsWithReferenced,
},
}; };
use turbopack_ecmascript::utils::StringifyJs; use turbopack_ecmascript::utils::StringifyJs;
...@@ -109,9 +111,13 @@ pub struct ClientReferenceManifest { ...@@ -109,9 +111,13 @@ pub struct ClientReferenceManifest {
impl OutputAssetsReference for ClientReferenceManifest { impl OutputAssetsReference for ClientReferenceManifest {
#[turbo_tasks::function] #[turbo_tasks::function]
async fn references(self: Vc<Self>) -> Result<Vc<OutputAssetsWithReferenced>> { async fn references(self: Vc<Self>) -> Result<Vc<OutputAssetsWithReferenced>> {
Ok(OutputAssetsWithReferenced::from_assets( Ok(OutputAssetsWithReferenced {
*build_manifest(self).await?.references, assets: ResolvedVc::cell(vec![]),
)) references: ResolvedVc::cell(vec![ResolvedVc::upcast(
build_manifest(self).await?.references,
)]),
}
.cell())
} }
} }
...@@ -140,7 +146,7 @@ impl Asset for ClientReferenceManifest { ...@@ -140,7 +146,7 @@ impl Asset for ClientReferenceManifest {
#[turbo_tasks::value(shared)] #[turbo_tasks::value(shared)]
struct ClientReferenceManifestResult { struct ClientReferenceManifestResult {
content: ResolvedVc<AssetContent>, content: ResolvedVc<AssetContent>,
references: ResolvedVc<OutputAssets>, references: ResolvedVc<OutputAssetsReferences>,
} }
#[turbo_tasks::function] #[turbo_tasks::function]
...@@ -166,7 +172,7 @@ async fn build_manifest( ...@@ -166,7 +172,7 @@ async fn build_manifest(
); );
async move { async move {
let mut entry_manifest: SerializedClientReferenceManifest = Default::default(); let mut entry_manifest: SerializedClientReferenceManifest = Default::default();
let mut references = FxIndexSet::default(); let mut references = Vec::new();
let chunk_suffix_path = next_config.chunk_suffix_path().owned().await?; let chunk_suffix_path = next_config.chunk_suffix_path().owned().await?;
let prefix_path = next_config.computed_asset_prefix().owned().await?; let prefix_path = next_config.computed_asset_prefix().owned().await?;
let suffix_path = chunk_suffix_path.unwrap_or_default(); let suffix_path = chunk_suffix_path.unwrap_or_default();
...@@ -259,13 +265,16 @@ async fn build_manifest( ...@@ -259,13 +265,16 @@ async fn build_manifest(
let (client_chunks_paths, client_is_async) = if let Some(client_assets) = let (client_chunks_paths, client_is_async) = if let Some(client_assets) =
client_component_client_chunks.get(&app_client_reference_ty) client_component_client_chunks.get(&app_client_reference_ty)
{ {
let client_chunks = client_assets.primary_assets().await?; let client_chunks = client_assets.primary_assets().to_resolved().await?;
let client_referenced_assets = client_assets.referenced_assets().await?; references.push(ResolvedVc::upcast(client_chunks));
references.extend(client_chunks.iter()); references.push(ResolvedVc::upcast(
references.extend(client_referenced_assets.iter()); client_assets.references().to_resolved().await?,
));
let client_chunks_paths =
cached_chunk_paths(&mut client_chunk_path_cache, client_chunks.iter().copied()) let client_chunks_paths = cached_chunk_paths(
&mut client_chunk_path_cache,
client_chunks.await?.into_iter().copied(),
)
.await?; .await?;
let chunk_paths = client_chunks_paths let chunk_paths = client_chunks_paths
...@@ -312,13 +321,15 @@ async fn build_manifest( ...@@ -312,13 +321,15 @@ async fn build_manifest(
} else if let Some(ssr_assets) = } else if let Some(ssr_assets) =
client_component_ssr_chunks.get(&app_client_reference_ty) client_component_ssr_chunks.get(&app_client_reference_ty)
{ {
let ssr_chunks = ssr_assets.primary_assets().await?; let ssr_chunks = ssr_assets.primary_assets().to_resolved().await?;
let ssr_referenced_assets = ssr_assets.referenced_assets().await?; let ssr_referenced_assets = ssr_assets.references().to_resolved().await?;
references.extend(ssr_chunks.iter()); references.push(ResolvedVc::upcast(ssr_chunks));
references.extend(ssr_referenced_assets.iter()); references.push(ResolvedVc::upcast(ssr_referenced_assets));
let ssr_chunks_paths = let ssr_chunks_paths = cached_chunk_paths(
cached_chunk_paths(&mut ssr_chunk_path_cache, ssr_chunks.iter().copied()) &mut ssr_chunk_path_cache,
ssr_chunks.await?.into_iter().copied(),
)
.await?; .await?;
let chunk_paths = ssr_chunks_paths let chunk_paths = ssr_chunks_paths
.filter_map(|(_, chunk_path)| { .filter_map(|(_, chunk_path)| {
......
...@@ -26,7 +26,7 @@ use turbopack_core::{ ...@@ -26,7 +26,7 @@ use turbopack_core::{
chunk_group_info::ChunkGroup, chunk_group_info::ChunkGroup,
export_usage::{ExportUsageInfo, ModuleExportUsage}, export_usage::{ExportUsageInfo, ModuleExportUsage},
}, },
output::{OutputAsset, OutputAssets}, output::{OutputAsset, OutputAssets, OutputAssetsReferences},
}; };
use turbopack_ecmascript::{ use turbopack_ecmascript::{
async_chunk::module::AsyncLoaderModule, async_chunk::module::AsyncLoaderModule,
...@@ -675,7 +675,7 @@ impl ChunkingContext for BrowserChunkingContext { ...@@ -675,7 +675,7 @@ impl ChunkingContext for BrowserChunkingContext {
let MakeChunkGroupResult { let MakeChunkGroupResult {
chunks, chunks,
referenced_output_assets, referenced_output_assets,
references, mut references,
availability_info, availability_info,
} = make_chunk_group( } = make_chunk_group(
entries, entries,
...@@ -691,6 +691,10 @@ impl ChunkingContext for BrowserChunkingContext { ...@@ -691,6 +691,10 @@ impl ChunkingContext for BrowserChunkingContext {
.try_join() .try_join()
.await?; .await?;
let referenced_output_assets: ResolvedVc<OutputAssets> =
ResolvedVc::cell(referenced_output_assets);
references.push(ResolvedVc::upcast(referenced_output_assets));
if this.enable_hot_module_replacement { if this.enable_hot_module_replacement {
let mut ident = ident; let mut ident = ident;
if let Some(input_availability_info_ident) = input_availability_info.ident().await? if let Some(input_availability_info_ident) = input_availability_info.ident().await?
...@@ -712,7 +716,6 @@ impl ChunkingContext for BrowserChunkingContext { ...@@ -712,7 +716,6 @@ impl ChunkingContext for BrowserChunkingContext {
Ok(ChunkGroupResult { Ok(ChunkGroupResult {
assets: ResolvedVc::cell(assets), assets: ResolvedVc::cell(assets),
referenced_assets: ResolvedVc::cell(referenced_output_assets),
references: ResolvedVc::cell(references), references: ResolvedVc::cell(references),
availability_info, availability_info,
} }
...@@ -741,7 +744,7 @@ impl ChunkingContext for BrowserChunkingContext { ...@@ -741,7 +744,7 @@ impl ChunkingContext for BrowserChunkingContext {
let MakeChunkGroupResult { let MakeChunkGroupResult {
chunks, chunks,
referenced_output_assets, referenced_output_assets,
references, mut references,
availability_info, availability_info,
} = make_chunk_group( } = make_chunk_group(
entries, entries,
...@@ -757,6 +760,10 @@ impl ChunkingContext for BrowserChunkingContext { ...@@ -757,6 +760,10 @@ impl ChunkingContext for BrowserChunkingContext {
.try_join() .try_join()
.await?; .await?;
let referenced_output_assets: ResolvedVc<OutputAssets> =
ResolvedVc::cell(referenced_output_assets);
references.push(ResolvedVc::upcast(referenced_output_assets));
let other_assets = Vc::cell(assets.clone()); let other_assets = Vc::cell(assets.clone());
let entries = Vc::cell( let entries = Vc::cell(
...@@ -795,7 +802,6 @@ impl ChunkingContext for BrowserChunkingContext { ...@@ -795,7 +802,6 @@ impl ChunkingContext for BrowserChunkingContext {
Ok(ChunkGroupResult { Ok(ChunkGroupResult {
assets: ResolvedVc::cell(assets), assets: ResolvedVc::cell(assets),
referenced_assets: ResolvedVc::cell(referenced_output_assets),
references: ResolvedVc::cell(references), references: ResolvedVc::cell(references),
availability_info, availability_info,
} }
...@@ -812,7 +818,7 @@ impl ChunkingContext for BrowserChunkingContext { ...@@ -812,7 +818,7 @@ impl ChunkingContext for BrowserChunkingContext {
_evaluatable_assets: Vc<EvaluatableAssets>, _evaluatable_assets: Vc<EvaluatableAssets>,
_module_graph: Vc<ModuleGraph>, _module_graph: Vc<ModuleGraph>,
_extra_chunks: Vc<OutputAssets>, _extra_chunks: Vc<OutputAssets>,
_extra_referenced_assets: Vc<OutputAssets>, _extra_references: Vc<OutputAssetsReferences>,
_availability_info: AvailabilityInfo, _availability_info: AvailabilityInfo,
) -> Result<Vc<EntryChunkGroupResult>> { ) -> Result<Vc<EntryChunkGroupResult>> {
bail!("Browser chunking context does not support entry chunk groups") bail!("Browser chunking context does not support entry chunk groups")
......
...@@ -117,7 +117,6 @@ impl OutputAssetsReference for EcmascriptBrowserChunk { ...@@ -117,7 +117,6 @@ impl OutputAssetsReference for EcmascriptBrowserChunk {
Ok(OutputAssetsWithReferenced { Ok(OutputAssetsWithReferenced {
assets: ResolvedVc::cell(assets), assets: ResolvedVc::cell(assets),
referenced_assets: chunk_references.referenced_assets,
references: chunk_references.references, references: chunk_references.references,
} }
.cell()) .cell())
......
...@@ -36,7 +36,7 @@ use turbopack_core::{ ...@@ -36,7 +36,7 @@ use turbopack_core::{
chunk_group_info::{ChunkGroup, ChunkGroupEntry}, chunk_group_info::{ChunkGroup, ChunkGroupEntry},
export_usage::compute_export_usage_info, export_usage::compute_export_usage_info,
}, },
output::{OutputAsset, OutputAssets, OutputAssetsWithReferenced}, output::{OutputAsset, OutputAssets, OutputAssetsReferences, OutputAssetsWithReferenced},
reference_type::{EntryReferenceSubType, ReferenceType}, reference_type::{EntryReferenceSubType, ReferenceType},
resolve::{ resolve::{
origin::{PlainResolveOrigin, ResolveOriginExt}, origin::{PlainResolveOrigin, ResolveOriginExt},
...@@ -464,13 +464,12 @@ async fn build_internal( ...@@ -464,13 +464,12 @@ async fn build_internal(
EvaluatableAssets::one(*ecmascript), EvaluatableAssets::one(*ecmascript),
module_graph, module_graph,
OutputAssets::empty(), OutputAssets::empty(),
OutputAssets::empty(), OutputAssetsReferences::empty(),
AvailabilityInfo::root(), AvailabilityInfo::root(),
) )
.await? .await?
.asset, .asset,
]), ]),
referenced_assets: ResolvedVc::cell(vec![]),
references: ResolvedVc::cell(vec![]), references: ResolvedVc::cell(vec![]),
} }
.cell(), .cell(),
......
...@@ -26,8 +26,7 @@ use crate::{ ...@@ -26,8 +26,7 @@ use crate::{
module_batches::{BatchingConfig, ModuleBatchesGraphEdge}, module_batches::{BatchingConfig, ModuleBatchesGraphEdge},
}, },
output::{ output::{
OutputAsset, OutputAssets, OutputAssetsReference, OutputAssetsReferences, OutputAsset, OutputAssetsReference, OutputAssetsReferences, OutputAssetsWithReferenced,
OutputAssetsWithReferenced,
}, },
reference::ModuleReference, reference::ModuleReference,
traced_asset::TracedAsset, traced_asset::TracedAsset,
...@@ -185,7 +184,6 @@ pub async fn references_to_output_assets( ...@@ -185,7 +184,6 @@ pub async fn references_to_output_assets(
.collect::<Vec<_>>(); .collect::<Vec<_>>();
Ok(OutputAssetsWithReferenced { Ok(OutputAssetsWithReferenced {
assets: ResolvedVc::cell(output_assets), assets: ResolvedVc::cell(output_assets),
referenced_assets: OutputAssets::empty_resolved(),
references: OutputAssetsReferences::empty_resolved(), references: OutputAssetsReferences::empty_resolved(),
} }
.cell()) .cell())
......
...@@ -93,7 +93,6 @@ pub enum ChunkGroupType { ...@@ -93,7 +93,6 @@ pub enum ChunkGroupType {
#[derive(Clone)] #[derive(Clone)]
pub struct ChunkGroupResult { pub struct ChunkGroupResult {
pub assets: ResolvedVc<OutputAssets>, pub assets: ResolvedVc<OutputAssets>,
pub referenced_assets: ResolvedVc<OutputAssets>,
pub references: ResolvedVc<OutputAssetsReferences>, pub references: ResolvedVc<OutputAssetsReferences>,
pub availability_info: AvailabilityInfo, pub availability_info: AvailabilityInfo,
} }
...@@ -102,7 +101,6 @@ impl ChunkGroupResult { ...@@ -102,7 +101,6 @@ impl ChunkGroupResult {
pub fn empty() -> Vc<Self> { pub fn empty() -> Vc<Self> {
ChunkGroupResult { ChunkGroupResult {
assets: ResolvedVc::cell(vec![]), assets: ResolvedVc::cell(vec![]),
referenced_assets: ResolvedVc::cell(vec![]),
references: ResolvedVc::cell(vec![]), references: ResolvedVc::cell(vec![]),
availability_info: AvailabilityInfo::root(), availability_info: AvailabilityInfo::root(),
} }
...@@ -112,7 +110,6 @@ impl ChunkGroupResult { ...@@ -112,7 +110,6 @@ impl ChunkGroupResult {
pub fn empty_resolved() -> ResolvedVc<Self> { pub fn empty_resolved() -> ResolvedVc<Self> {
ChunkGroupResult { ChunkGroupResult {
assets: ResolvedVc::cell(vec![]), assets: ResolvedVc::cell(vec![]),
referenced_assets: ResolvedVc::cell(vec![]),
references: ResolvedVc::cell(vec![]), references: ResolvedVc::cell(vec![]),
availability_info: AvailabilityInfo::root(), availability_info: AvailabilityInfo::root(),
} }
...@@ -126,7 +123,6 @@ impl ChunkGroupResult { ...@@ -126,7 +123,6 @@ impl ChunkGroupResult {
pub async fn output_assets_with_referenced(&self) -> Result<Vc<OutputAssetsWithReferenced>> { pub async fn output_assets_with_referenced(&self) -> Result<Vc<OutputAssetsWithReferenced>> {
Ok(OutputAssetsWithReferenced { Ok(OutputAssetsWithReferenced {
assets: self.assets, assets: self.assets,
referenced_assets: self.referenced_assets,
references: self.references, references: self.references,
} }
.cell()) .cell())
...@@ -137,11 +133,6 @@ impl ChunkGroupResult { ...@@ -137,11 +133,6 @@ impl ChunkGroupResult {
let next = next.await?; let next = next.await?;
Ok(ChunkGroupResult { Ok(ChunkGroupResult {
assets: self.assets.concatenate(*next.assets).to_resolved().await?, assets: self.assets.concatenate(*next.assets).to_resolved().await?,
referenced_assets: self
.referenced_assets
.concatenate(*next.referenced_assets)
.to_resolved()
.await?,
references: self references: self
.references .references
.concatenate(*next.references) .concatenate(*next.references)
...@@ -159,7 +150,6 @@ impl ChunkGroupResult { ...@@ -159,7 +150,6 @@ impl ChunkGroupResult {
self.assets self.assets
.await? .await?
.into_iter() .into_iter()
.chain(self.referenced_assets.await?.into_iter())
.copied() .copied()
.map(ExpandOutputAssetsInput::Asset) .map(ExpandOutputAssetsInput::Asset)
.chain( .chain(
...@@ -183,25 +173,8 @@ impl ChunkGroupResult { ...@@ -183,25 +173,8 @@ impl ChunkGroupResult {
} }
#[turbo_tasks::function] #[turbo_tasks::function]
pub async fn referenced_assets(&self) -> Result<Vc<OutputAssets>> { pub fn references(&self) -> Vc<OutputAssetsReferences> {
Ok(Vc::cell( *self.references
expand_output_assets(
self.referenced_assets
.await?
.into_iter()
.copied()
.map(ExpandOutputAssetsInput::Asset)
.chain(
self.references
.await?
.into_iter()
.copied()
.map(ExpandOutputAssetsInput::Reference),
),
false,
)
.await?,
))
} }
} }
...@@ -412,7 +385,7 @@ pub trait ChunkingContext { ...@@ -412,7 +385,7 @@ pub trait ChunkingContext {
evaluatable_assets: Vc<EvaluatableAssets>, evaluatable_assets: Vc<EvaluatableAssets>,
module_graph: Vc<ModuleGraph>, module_graph: Vc<ModuleGraph>,
extra_chunks: Vc<OutputAssets>, extra_chunks: Vc<OutputAssets>,
extra_referenced_assets: Vc<OutputAssets>, extra_references: Vc<OutputAssetsReferences>,
availability_info: AvailabilityInfo, availability_info: AvailabilityInfo,
) -> Result<Vc<EntryChunkGroupResult>>; ) -> Result<Vc<EntryChunkGroupResult>>;
...@@ -477,7 +450,7 @@ pub trait ChunkingContextExt { ...@@ -477,7 +450,7 @@ pub trait ChunkingContextExt {
evaluatable_assets: Vc<EvaluatableAssets>, evaluatable_assets: Vc<EvaluatableAssets>,
module_graph: Vc<ModuleGraph>, module_graph: Vc<ModuleGraph>,
extra_chunks: Vc<OutputAssets>, extra_chunks: Vc<OutputAssets>,
extra_referenced_assets: Vc<OutputAssets>, extra_references: Vc<OutputAssetsReferences>,
availability_info: AvailabilityInfo, availability_info: AvailabilityInfo,
) -> Vc<Box<dyn OutputAsset>> ) -> Vc<Box<dyn OutputAsset>>
where where
...@@ -489,7 +462,7 @@ pub trait ChunkingContextExt { ...@@ -489,7 +462,7 @@ pub trait ChunkingContextExt {
evaluatable_assets: Vc<EvaluatableAssets>, evaluatable_assets: Vc<EvaluatableAssets>,
module_graph: Vc<ModuleGraph>, module_graph: Vc<ModuleGraph>,
extra_chunks: Vc<OutputAssets>, extra_chunks: Vc<OutputAssets>,
extra_referenced_assets: Vc<OutputAssets>, extra_references: Vc<OutputAssetsReferences>,
) -> Vc<EntryChunkGroupResult> ) -> Vc<EntryChunkGroupResult>
where where
Self: Send; Self: Send;
...@@ -500,7 +473,7 @@ pub trait ChunkingContextExt { ...@@ -500,7 +473,7 @@ pub trait ChunkingContextExt {
evaluatable_assets: Vc<EvaluatableAssets>, evaluatable_assets: Vc<EvaluatableAssets>,
module_graph: Vc<ModuleGraph>, module_graph: Vc<ModuleGraph>,
extra_chunks: Vc<OutputAssets>, extra_chunks: Vc<OutputAssets>,
extra_referenced_assets: Vc<OutputAssets>, extra_references: Vc<OutputAssetsReferences>,
) -> Vc<Box<dyn OutputAsset>> ) -> Vc<Box<dyn OutputAsset>>
where where
Self: Send; Self: Send;
...@@ -569,7 +542,7 @@ impl<T: ChunkingContext + Send + Upcast<Box<dyn ChunkingContext>>> ChunkingConte ...@@ -569,7 +542,7 @@ impl<T: ChunkingContext + Send + Upcast<Box<dyn ChunkingContext>>> ChunkingConte
evaluatable_assets: Vc<EvaluatableAssets>, evaluatable_assets: Vc<EvaluatableAssets>,
module_graph: Vc<ModuleGraph>, module_graph: Vc<ModuleGraph>,
extra_chunks: Vc<OutputAssets>, extra_chunks: Vc<OutputAssets>,
extra_referenced_assets: Vc<OutputAssets>, extra_references: Vc<OutputAssetsReferences>,
availability_info: AvailabilityInfo, availability_info: AvailabilityInfo,
) -> Vc<Box<dyn OutputAsset>> { ) -> Vc<Box<dyn OutputAsset>> {
entry_chunk_group_asset( entry_chunk_group_asset(
...@@ -578,7 +551,7 @@ impl<T: ChunkingContext + Send + Upcast<Box<dyn ChunkingContext>>> ChunkingConte ...@@ -578,7 +551,7 @@ impl<T: ChunkingContext + Send + Upcast<Box<dyn ChunkingContext>>> ChunkingConte
evaluatable_assets, evaluatable_assets,
module_graph, module_graph,
extra_chunks, extra_chunks,
extra_referenced_assets, extra_references,
availability_info, availability_info,
) )
} }
...@@ -589,14 +562,14 @@ impl<T: ChunkingContext + Send + Upcast<Box<dyn ChunkingContext>>> ChunkingConte ...@@ -589,14 +562,14 @@ impl<T: ChunkingContext + Send + Upcast<Box<dyn ChunkingContext>>> ChunkingConte
evaluatable_assets: Vc<EvaluatableAssets>, evaluatable_assets: Vc<EvaluatableAssets>,
module_graph: Vc<ModuleGraph>, module_graph: Vc<ModuleGraph>,
extra_chunks: Vc<OutputAssets>, extra_chunks: Vc<OutputAssets>,
extra_referenced_assets: Vc<OutputAssets>, extra_references: Vc<OutputAssetsReferences>,
) -> Vc<EntryChunkGroupResult> { ) -> Vc<EntryChunkGroupResult> {
self.entry_chunk_group( self.entry_chunk_group(
path, path,
evaluatable_assets, evaluatable_assets,
module_graph, module_graph,
extra_chunks, extra_chunks,
extra_referenced_assets, extra_references,
AvailabilityInfo::root(), AvailabilityInfo::root(),
) )
} }
...@@ -607,7 +580,7 @@ impl<T: ChunkingContext + Send + Upcast<Box<dyn ChunkingContext>>> ChunkingConte ...@@ -607,7 +580,7 @@ impl<T: ChunkingContext + Send + Upcast<Box<dyn ChunkingContext>>> ChunkingConte
evaluatable_assets: Vc<EvaluatableAssets>, evaluatable_assets: Vc<EvaluatableAssets>,
module_graph: Vc<ModuleGraph>, module_graph: Vc<ModuleGraph>,
extra_chunks: Vc<OutputAssets>, extra_chunks: Vc<OutputAssets>,
extra_referenced_assets: Vc<OutputAssets>, extra_references: Vc<OutputAssetsReferences>,
) -> Vc<Box<dyn OutputAsset>> { ) -> Vc<Box<dyn OutputAsset>> {
entry_chunk_group_asset( entry_chunk_group_asset(
Vc::upcast_non_strict(self), Vc::upcast_non_strict(self),
...@@ -615,7 +588,7 @@ impl<T: ChunkingContext + Send + Upcast<Box<dyn ChunkingContext>>> ChunkingConte ...@@ -615,7 +588,7 @@ impl<T: ChunkingContext + Send + Upcast<Box<dyn ChunkingContext>>> ChunkingConte
evaluatable_assets, evaluatable_assets,
module_graph, module_graph,
extra_chunks, extra_chunks,
extra_referenced_assets, extra_references,
AvailabilityInfo::root(), AvailabilityInfo::root(),
) )
} }
...@@ -715,7 +688,7 @@ async fn entry_chunk_group_asset( ...@@ -715,7 +688,7 @@ async fn entry_chunk_group_asset(
evaluatable_assets: Vc<EvaluatableAssets>, evaluatable_assets: Vc<EvaluatableAssets>,
module_graph: Vc<ModuleGraph>, module_graph: Vc<ModuleGraph>,
extra_chunks: Vc<OutputAssets>, extra_chunks: Vc<OutputAssets>,
extra_referenced_assets: Vc<OutputAssets>, extra_references: Vc<OutputAssetsReferences>,
availability_info: AvailabilityInfo, availability_info: AvailabilityInfo,
) -> Result<Vc<Box<dyn OutputAsset>>> { ) -> Result<Vc<Box<dyn OutputAsset>>> {
Ok(*chunking_context Ok(*chunking_context
...@@ -724,7 +697,7 @@ async fn entry_chunk_group_asset( ...@@ -724,7 +697,7 @@ async fn entry_chunk_group_asset(
evaluatable_assets, evaluatable_assets,
module_graph, module_graph,
extra_chunks, extra_chunks,
extra_referenced_assets, extra_references,
availability_info, availability_info,
) )
.await? .await?
......
...@@ -2,7 +2,7 @@ use anyhow::Result; ...@@ -2,7 +2,7 @@ use anyhow::Result;
use either::Either; use either::Either;
use turbo_rcstr::RcStr; use turbo_rcstr::RcStr;
use turbo_tasks::{ use turbo_tasks::{
FxIndexSet, ResolvedVc, ValueToString, Vc, FxIndexSet, ResolvedVc, TryJoinIterExt, ValueToString, Vc,
graph::{AdjacencyMap, GraphTraversal}, graph::{AdjacencyMap, GraphTraversal},
}; };
use turbo_tasks_fs::FileSystemPath; use turbo_tasks_fs::FileSystemPath;
...@@ -19,7 +19,6 @@ pub trait OutputAssetsReference { ...@@ -19,7 +19,6 @@ pub trait OutputAssetsReference {
fn references(self: Vc<Self>) -> Vc<OutputAssetsWithReferenced> { fn references(self: Vc<Self>) -> Vc<OutputAssetsWithReferenced> {
OutputAssetsWithReferenced { OutputAssetsWithReferenced {
assets: OutputAssets::empty_resolved(), assets: OutputAssets::empty_resolved(),
referenced_assets: OutputAssets::empty_resolved(),
references: OutputAssetsReferences::empty_resolved(), references: OutputAssetsReferences::empty_resolved(),
} }
.cell() .cell()
...@@ -59,6 +58,24 @@ impl OutputAssetsReferences { ...@@ -59,6 +58,24 @@ impl OutputAssetsReferences {
references.extend(other.await?.iter().copied()); references.extend(other.await?.iter().copied());
Ok(Vc::cell(references.into_iter().collect())) Ok(Vc::cell(references.into_iter().collect()))
} }
/// Returns only direct referenced assets and does not include assets referenced indirectly by
/// them.
#[turbo_tasks::function]
pub async fn all_assets(&self) -> Result<Vc<OutputAssets>> {
let mut assets: FxIndexSet<_> = FxIndexSet::default();
for reference in &self.0 {
assets.extend(
reference
.references()
.all_assets()
.await?
.into_iter()
.copied(),
);
}
Ok(Vc::cell(assets.into_iter().collect()))
}
} }
impl OutputAssetsReferences { impl OutputAssetsReferences {
pub fn empty() -> Vc<Self> { pub fn empty() -> Vc<Self> {
...@@ -70,6 +87,30 @@ impl OutputAssetsReferences { ...@@ -70,6 +87,30 @@ impl OutputAssetsReferences {
} }
} }
#[turbo_tasks::value_impl]
impl OutputAssetsReference for OutputAssetsReferences {
#[turbo_tasks::function]
async fn references(self: Vc<Self>) -> Result<Vc<OutputAssetsWithReferenced>> {
let refs_references = self
.await?
.into_iter()
.map(async |&reference| reference.references().await)
.try_join()
.await?;
let mut assets = Vec::new();
let mut references = Vec::new();
for r in refs_references {
assets.extend(r.assets.await?.iter().copied());
references.extend(r.references.await?.iter().copied());
}
Ok(OutputAssetsWithReferenced {
assets: ResolvedVc::cell(assets),
references: ResolvedVc::cell(references),
}
.cell())
}
}
#[turbo_tasks::value(transparent)] #[turbo_tasks::value(transparent)]
pub struct OutputAssets(Vec<ResolvedVc<Box<dyn OutputAsset>>>); pub struct OutputAssets(Vec<ResolvedVc<Box<dyn OutputAsset>>>);
...@@ -102,6 +143,18 @@ impl OutputAssets { ...@@ -102,6 +143,18 @@ impl OutputAssets {
} }
} }
#[turbo_tasks::value_impl]
impl OutputAssetsReference for OutputAssets {
#[turbo_tasks::function]
fn references(self: ResolvedVc<Self>) -> Vc<OutputAssetsWithReferenced> {
OutputAssetsWithReferenced {
assets: self,
references: OutputAssetsReferences::empty_resolved(),
}
.cell()
}
}
#[turbo_tasks::value(transparent)] #[turbo_tasks::value(transparent)]
pub struct ExpandedOutputAssets(Vec<ResolvedVc<Box<dyn OutputAsset>>>); pub struct ExpandedOutputAssets(Vec<ResolvedVc<Box<dyn OutputAsset>>>);
...@@ -114,8 +167,6 @@ pub struct OutputAssetsSet(FxIndexSet<ResolvedVc<Box<dyn OutputAsset>>>); ...@@ -114,8 +167,6 @@ pub struct OutputAssetsSet(FxIndexSet<ResolvedVc<Box<dyn OutputAsset>>>);
pub struct OutputAssetsWithReferenced { pub struct OutputAssetsWithReferenced {
/// Primary output assets. These are e. g. the chunks needed for a chunk group. /// Primary output assets. These are e. g. the chunks needed for a chunk group.
pub assets: ResolvedVc<OutputAssets>, pub assets: ResolvedVc<OutputAssets>,
/// Secondary output assets that are referenced by the primary assets.
pub referenced_assets: ResolvedVc<OutputAssets>,
/// Secondary output assets that are referenced by the primary assets. These are unresolved /// Secondary output assets that are referenced by the primary assets. These are unresolved
/// `OutputAssetsReference`s and need to be expanded to get the actual assets. These are e. g. /// `OutputAssetsReference`s and need to be expanded to get the actual assets. These are e. g.
/// async loaders that reference other chunk groups. /// async loaders that reference other chunk groups.
...@@ -131,7 +182,6 @@ impl OutputAssetsWithReferenced { ...@@ -131,7 +182,6 @@ impl OutputAssetsWithReferenced {
self.assets self.assets
.await? .await?
.into_iter() .into_iter()
.chain(self.referenced_assets.await?.into_iter())
.map(|&asset| ExpandOutputAssetsInput::Asset(asset)) .map(|&asset| ExpandOutputAssetsInput::Asset(asset))
.chain( .chain(
self.references self.references
...@@ -151,7 +201,6 @@ impl OutputAssetsWithReferenced { ...@@ -151,7 +201,6 @@ impl OutputAssetsWithReferenced {
pub fn from_assets(assets: ResolvedVc<OutputAssets>) -> Vc<Self> { pub fn from_assets(assets: ResolvedVc<OutputAssets>) -> Vc<Self> {
OutputAssetsWithReferenced { OutputAssetsWithReferenced {
assets, assets,
referenced_assets: OutputAssets::empty_resolved(),
references: OutputAssetsReferences::empty_resolved(), references: OutputAssetsReferences::empty_resolved(),
} }
.cell() .cell()
...@@ -165,11 +214,6 @@ impl OutputAssetsWithReferenced { ...@@ -165,11 +214,6 @@ impl OutputAssetsWithReferenced {
.concatenate(*other.await?.assets) .concatenate(*other.await?.assets)
.to_resolved() .to_resolved()
.await?, .await?,
referenced_assets: self
.referenced_assets
.concatenate(*other.await?.referenced_assets)
.to_resolved()
.await?,
references: self references: self
.references .references
.concatenate(*other.await?.references) .concatenate(*other.await?.references)
...@@ -199,28 +243,11 @@ impl OutputAssetsWithReferenced { ...@@ -199,28 +243,11 @@ impl OutputAssetsWithReferenced {
*self.assets *self.assets
} }
/// Returns only secondary referenced asset entries. Doesn't expand OutputAssets. Doesn't return /// Returns only secondary referenced asset entries. Doesn't return
/// primary assets. /// primary assets.
#[turbo_tasks::function] #[turbo_tasks::function]
pub async fn referenced_assets(&self) -> Result<Vc<OutputAssets>> { pub fn references(&self) -> Vc<OutputAssetsReferences> {
Ok(Vc::cell( *self.references
expand_output_assets(
self.referenced_assets
.await?
.into_iter()
.copied()
.map(ExpandOutputAssetsInput::Asset)
.chain(
self.references
.await?
.into_iter()
.copied()
.map(ExpandOutputAssetsInput::Reference),
),
false,
)
.await?,
))
} }
} }
...@@ -242,7 +269,6 @@ async fn get_referenced_assets( ...@@ -242,7 +269,6 @@ async fn get_referenced_assets(
.assets .assets
.await? .await?
.into_iter() .into_iter()
.chain(refs.referenced_assets.await?.into_iter())
.map(|&asset| ExpandOutputAssetsInput::Asset(asset)) .map(|&asset| ExpandOutputAssetsInput::Asset(asset))
.chain( .chain(
refs.references refs.references
......
...@@ -273,12 +273,7 @@ impl OutputAssetsReference for CssChunk { ...@@ -273,12 +273,7 @@ impl OutputAssetsReference for CssChunk {
} else { } else {
None None
}; };
Ok(( Ok((refs.assets.await?, single_css_chunk, refs.references.await?))
refs.assets.await?,
single_css_chunk,
refs.referenced_assets.await?,
refs.references.await?,
))
}) })
.try_join() .try_join()
.await?; .await?;
...@@ -298,7 +293,7 @@ impl OutputAssetsReference for CssChunk { ...@@ -298,7 +293,7 @@ impl OutputAssetsReference for CssChunk {
assets: ResolvedVc::cell( assets: ResolvedVc::cell(
references references
.iter() .iter()
.flat_map(|(assets, single_css_chunk, _, _)| { .flat_map(|(assets, single_css_chunk, _)| {
assets assets
.iter() .iter()
.copied() .copied()
...@@ -307,16 +302,10 @@ impl OutputAssetsReference for CssChunk { ...@@ -307,16 +302,10 @@ impl OutputAssetsReference for CssChunk {
.chain(source_map.into_iter()) .chain(source_map.into_iter())
.collect(), .collect(),
), ),
referenced_assets: ResolvedVc::cell(
references
.iter()
.flat_map(|(_, _, referenced_assets, _)| referenced_assets.iter().copied())
.collect(),
),
references: ResolvedVc::cell( references: ResolvedVc::cell(
references references
.iter() .iter()
.flat_map(|(_, _, _, references)| references.iter().copied()) .flat_map(|(_, _, references)| references.iter().copied())
.collect(), .collect(),
), ),
} }
......
...@@ -178,7 +178,6 @@ impl DevHtmlAsset { ...@@ -178,7 +178,6 @@ impl DevHtmlAsset {
Ok(( Ok((
asset_with_referenced.assets.await?, asset_with_referenced.assets.await?,
asset_with_referenced.referenced_assets.await?,
asset_with_referenced.references.await?, asset_with_referenced.references.await?,
)) ))
}) })
...@@ -186,17 +185,14 @@ impl DevHtmlAsset { ...@@ -186,17 +185,14 @@ impl DevHtmlAsset {
.await?; .await?;
let mut all_assets = Vec::new(); let mut all_assets = Vec::new();
let mut all_referenced_assets = Vec::new();
let mut all_references = Vec::new(); let mut all_references = Vec::new();
for (asset, referenced_asset, reference) in all_chunk_groups { for (asset, reference) in all_chunk_groups {
all_assets.extend(asset); all_assets.extend(asset);
all_referenced_assets.extend(referenced_asset);
all_references.extend(reference); all_references.extend(reference);
} }
Ok(OutputAssetsWithReferenced { Ok(OutputAssetsWithReferenced {
assets: ResolvedVc::cell(all_assets), assets: ResolvedVc::cell(all_assets),
referenced_assets: ResolvedVc::cell(all_referenced_assets),
references: ResolvedVc::cell(all_references), references: ResolvedVc::cell(all_references),
} }
.cell()) .cell())
......
...@@ -155,11 +155,7 @@ async fn expand( ...@@ -155,11 +155,7 @@ async fn expand(
for &reference in refs.references.await?.iter() { for &reference in refs.references.await?.iter() {
queue.push_back(reference); queue.push_back(reference);
} }
let ref_assets = refs let ref_assets = refs.assets.await?;
.assets
.await?
.into_iter()
.chain(refs.referenced_assets.await?.into_iter());
for &asset in ref_assets { for &asset in ref_assets {
if assets_set.insert(asset) { if assets_set.insert(asset) {
let path = asset.path().await?; let path = asset.path().await?;
......
...@@ -49,7 +49,6 @@ impl AsyncLoaderChunkItem { ...@@ -49,7 +49,6 @@ impl AsyncLoaderChunkItem {
{ {
return Ok(OutputAssetsWithReferenced { return Ok(OutputAssetsWithReferenced {
assets: ResolvedVc::cell(vec![]), assets: ResolvedVc::cell(vec![]),
referenced_assets: ResolvedVc::cell(vec![]),
references: ResolvedVc::cell(vec![]), references: ResolvedVc::cell(vec![]),
} }
.cell()); .cell());
......
...@@ -71,18 +71,15 @@ impl EcmascriptChunkBatchWithAsyncInfo { ...@@ -71,18 +71,15 @@ impl EcmascriptChunkBatchWithAsyncInfo {
#[turbo_tasks::function] #[turbo_tasks::function]
pub async fn references(&self) -> Result<Vc<OutputAssetsWithReferenced>> { pub async fn references(&self) -> Result<Vc<OutputAssetsWithReferenced>> {
let mut output_assets = Vec::new(); let mut output_assets = Vec::new();
let mut referenced_output_assets = Vec::new();
let mut references = Vec::new(); let mut references = Vec::new();
// We expect most references to be empty, and avoiding try_join to avoid allocating the Vec // We expect most references to be empty, and avoiding try_join to avoid allocating the Vec
for item in &self.chunk_items { for item in &self.chunk_items {
let r = item.chunk_item.references().await?; let r = item.chunk_item.references().await?;
output_assets.extend(r.assets.await?); output_assets.extend(r.assets.await?);
referenced_output_assets.extend(r.referenced_assets.await?);
references.extend(r.references.await?); references.extend(r.references.await?);
} }
Ok(OutputAssetsWithReferenced { Ok(OutputAssetsWithReferenced {
assets: ResolvedVc::cell(output_assets), assets: ResolvedVc::cell(output_assets),
referenced_assets: ResolvedVc::cell(referenced_output_assets),
references: ResolvedVc::cell(references), references: ResolvedVc::cell(references),
} }
.cell()) .cell())
......
...@@ -76,11 +76,7 @@ impl OutputAssetsReference for EcmascriptChunk { ...@@ -76,11 +76,7 @@ impl OutputAssetsReference for EcmascriptChunk {
.iter() .iter()
.map(async |with_info| { .map(async |with_info| {
let r = with_info.references().await?; let r = with_info.references().await?;
Ok(( Ok((r.assets.await?, r.references.await?))
r.assets.await?,
r.referenced_assets.await?,
r.references.await?,
))
}) })
.try_join() .try_join()
.await?; .await?;
...@@ -88,19 +84,13 @@ impl OutputAssetsReference for EcmascriptChunk { ...@@ -88,19 +84,13 @@ impl OutputAssetsReference for EcmascriptChunk {
assets: ResolvedVc::cell( assets: ResolvedVc::cell(
references references
.iter() .iter()
.flat_map(|(assets, _, _)| assets.into_iter().copied()) .flat_map(|(assets, _)| assets.into_iter().copied())
.collect(),
),
referenced_assets: ResolvedVc::cell(
references
.iter()
.flat_map(|(_, referenced_assets, _)| referenced_assets.into_iter().copied())
.collect(), .collect(),
), ),
references: ResolvedVc::cell( references: ResolvedVc::cell(
references references
.iter() .iter()
.flat_map(|(_, _, references)| references.into_iter().copied()) .flat_map(|(_, references)| references.into_iter().copied())
.collect(), .collect(),
), ),
} }
......
...@@ -82,7 +82,6 @@ impl ManifestAsyncModule { ...@@ -82,7 +82,6 @@ impl ManifestAsyncModule {
{ {
return Ok(OutputAssetsWithReferenced { return Ok(OutputAssetsWithReferenced {
assets: ResolvedVc::cell(vec![]), assets: ResolvedVc::cell(vec![]),
referenced_assets: ResolvedVc::cell(vec![]),
references: ResolvedVc::cell(vec![]), references: ResolvedVc::cell(vec![]),
} }
.cell()); .cell());
......
...@@ -25,7 +25,7 @@ use turbopack_core::{ ...@@ -25,7 +25,7 @@ use turbopack_core::{
}, },
module::Module, module::Module,
module_graph::{GraphEntries, ModuleGraph, chunk_group_info::ChunkGroupEntry}, module_graph::{GraphEntries, ModuleGraph, chunk_group_info::ChunkGroupEntry},
output::{OutputAsset, OutputAssets}, output::{OutputAsset, OutputAssets, OutputAssetsReferences},
reference_type::{InnerAssets, ReferenceType}, reference_type::{InnerAssets, ReferenceType},
source::Source, source::Source,
virtual_source::VirtualSource, virtual_source::VirtualSource,
...@@ -94,7 +94,7 @@ async fn emit_evaluate_pool_assets_operation( ...@@ -94,7 +94,7 @@ async fn emit_evaluate_pool_assets_operation(
Vc::cell(entries.clone()), Vc::cell(entries.clone()),
*module_graph, *module_graph,
OutputAssets::empty(), OutputAssets::empty(),
OutputAssets::empty(), OutputAssetsReferences::empty(),
); );
let output_root = chunking_context.output_root().owned().await?; let output_root = chunking_context.output_root().owned().await?;
......
...@@ -16,7 +16,10 @@ use turbopack_core::{ ...@@ -16,7 +16,10 @@ use turbopack_core::{
chunk::{ChunkingContext, ChunkingContextExt, EvaluatableAsset, EvaluatableAssets}, chunk::{ChunkingContext, ChunkingContextExt, EvaluatableAsset, EvaluatableAssets},
module::Module, module::Module,
module_graph::{ModuleGraph, chunk_group_info::ChunkGroupEntry}, module_graph::{ModuleGraph, chunk_group_info::ChunkGroupEntry},
output::{ExpandOutputAssetsInput, OutputAsset, OutputAssets, expand_output_assets}, output::{
ExpandOutputAssetsInput, OutputAsset, OutputAssets, OutputAssetsReferences,
expand_output_assets,
},
source_map::GenerateSourceMap, source_map::GenerateSourceMap,
virtual_output::VirtualOutputAsset, virtual_output::VirtualOutputAsset,
}; };
...@@ -192,7 +195,7 @@ pub async fn get_intermediate_asset( ...@@ -192,7 +195,7 @@ pub async fn get_intermediate_asset(
false, false,
), ),
OutputAssets::empty(), OutputAssets::empty(),
OutputAssets::empty(), OutputAssetsReferences::empty(),
)) ))
} }
......
...@@ -21,7 +21,7 @@ use turbopack_core::{ ...@@ -21,7 +21,7 @@ use turbopack_core::{
chunk_group_info::ChunkGroup, chunk_group_info::ChunkGroup,
export_usage::{ExportUsageInfo, ModuleExportUsage}, export_usage::{ExportUsageInfo, ModuleExportUsage},
}, },
output::{OutputAsset, OutputAssets}, output::{OutputAsset, OutputAssets, OutputAssetsReferences},
}; };
use turbopack_ecmascript::{ use turbopack_ecmascript::{
async_chunk::module::AsyncLoaderModule, async_chunk::module::AsyncLoaderModule,
...@@ -439,7 +439,7 @@ impl ChunkingContext for NodeJsChunkingContext { ...@@ -439,7 +439,7 @@ impl ChunkingContext for NodeJsChunkingContext {
let MakeChunkGroupResult { let MakeChunkGroupResult {
chunks, chunks,
referenced_output_assets, referenced_output_assets,
references, mut references,
availability_info, availability_info,
} = make_chunk_group( } = make_chunk_group(
modules, modules,
...@@ -449,6 +449,10 @@ impl ChunkingContext for NodeJsChunkingContext { ...@@ -449,6 +449,10 @@ impl ChunkingContext for NodeJsChunkingContext {
) )
.await?; .await?;
let referenced_output_assets: ResolvedVc<OutputAssets> =
ResolvedVc::cell(referenced_output_assets);
references.push(ResolvedVc::upcast(referenced_output_assets));
let assets = chunks let assets = chunks
.iter() .iter()
.map(|chunk| self.generate_chunk(**chunk).to_resolved()) .map(|chunk| self.generate_chunk(**chunk).to_resolved())
...@@ -457,7 +461,6 @@ impl ChunkingContext for NodeJsChunkingContext { ...@@ -457,7 +461,6 @@ impl ChunkingContext for NodeJsChunkingContext {
Ok(ChunkGroupResult { Ok(ChunkGroupResult {
assets: ResolvedVc::cell(assets), assets: ResolvedVc::cell(assets),
referenced_assets: ResolvedVc::cell(referenced_output_assets),
references: ResolvedVc::cell(references), references: ResolvedVc::cell(references),
availability_info, availability_info,
} }
...@@ -474,7 +477,7 @@ impl ChunkingContext for NodeJsChunkingContext { ...@@ -474,7 +477,7 @@ impl ChunkingContext for NodeJsChunkingContext {
evaluatable_assets: Vc<EvaluatableAssets>, evaluatable_assets: Vc<EvaluatableAssets>,
module_graph: Vc<ModuleGraph>, module_graph: Vc<ModuleGraph>,
extra_chunks: Vc<OutputAssets>, extra_chunks: Vc<OutputAssets>,
extra_referenced_assets: Vc<OutputAssets>, extra_references: ResolvedVc<OutputAssetsReferences>,
availability_info: AvailabilityInfo, availability_info: AvailabilityInfo,
) -> Result<Vc<EntryChunkGroupResult>> { ) -> Result<Vc<EntryChunkGroupResult>> {
let span = tracing::info_span!( let span = tracing::info_span!(
...@@ -490,8 +493,8 @@ impl ChunkingContext for NodeJsChunkingContext { ...@@ -490,8 +493,8 @@ impl ChunkingContext for NodeJsChunkingContext {
let MakeChunkGroupResult { let MakeChunkGroupResult {
chunks, chunks,
mut referenced_output_assets, referenced_output_assets,
references, mut references,
availability_info, availability_info,
} = make_chunk_group( } = make_chunk_group(
entries, entries,
...@@ -509,7 +512,11 @@ impl ChunkingContext for NodeJsChunkingContext { ...@@ -509,7 +512,11 @@ impl ChunkingContext for NodeJsChunkingContext {
.await?; .await?;
other_chunks.extend(extra_chunks.iter().copied()); other_chunks.extend(extra_chunks.iter().copied());
referenced_output_assets.extend(extra_referenced_assets.await?.iter().copied()); let referenced_output_assets: ResolvedVc<OutputAssets> =
ResolvedVc::cell(referenced_output_assets);
references.push(ResolvedVc::upcast(referenced_output_assets));
references.push(ResolvedVc::upcast(extra_references));
let Some(module) = ResolvedVc::try_sidecast(*evaluatable_assets_ref.last().unwrap()) let Some(module) = ResolvedVc::try_sidecast(*evaluatable_assets_ref.last().unwrap())
else { else {
...@@ -522,7 +529,6 @@ impl ChunkingContext for NodeJsChunkingContext { ...@@ -522,7 +529,6 @@ impl ChunkingContext for NodeJsChunkingContext {
Vc::cell(other_chunks), Vc::cell(other_chunks),
evaluatable_assets, evaluatable_assets,
*module, *module,
Vc::cell(referenced_output_assets),
Vc::cell(references), Vc::cell(references),
module_graph, module_graph,
*self, *self,
......
...@@ -96,7 +96,6 @@ impl OutputAssetsReference for EcmascriptBuildNodeChunk { ...@@ -96,7 +96,6 @@ impl OutputAssetsReference for EcmascriptBuildNodeChunk {
Ok(OutputAssetsWithReferenced { Ok(OutputAssetsWithReferenced {
assets: ResolvedVc::cell(assets), assets: ResolvedVc::cell(assets),
referenced_assets: chunk_references.referenced_assets,
references: chunk_references.references, references: chunk_references.references,
} }
.cell()) .cell())
......
...@@ -29,7 +29,6 @@ pub(crate) struct EcmascriptBuildNodeEntryChunk { ...@@ -29,7 +29,6 @@ pub(crate) struct EcmascriptBuildNodeEntryChunk {
other_chunks: ResolvedVc<OutputAssets>, other_chunks: ResolvedVc<OutputAssets>,
evaluatable_assets: ResolvedVc<EvaluatableAssets>, evaluatable_assets: ResolvedVc<EvaluatableAssets>,
exported_module: ResolvedVc<Box<dyn EcmascriptChunkPlaceable>>, exported_module: ResolvedVc<Box<dyn EcmascriptChunkPlaceable>>,
referenced_output_assets: ResolvedVc<OutputAssets>,
references: ResolvedVc<OutputAssetsReferences>, references: ResolvedVc<OutputAssetsReferences>,
module_graph: ResolvedVc<ModuleGraph>, module_graph: ResolvedVc<ModuleGraph>,
chunking_context: ResolvedVc<NodeJsChunkingContext>, chunking_context: ResolvedVc<NodeJsChunkingContext>,
...@@ -44,7 +43,6 @@ impl EcmascriptBuildNodeEntryChunk { ...@@ -44,7 +43,6 @@ impl EcmascriptBuildNodeEntryChunk {
other_chunks: ResolvedVc<OutputAssets>, other_chunks: ResolvedVc<OutputAssets>,
evaluatable_assets: ResolvedVc<EvaluatableAssets>, evaluatable_assets: ResolvedVc<EvaluatableAssets>,
exported_module: ResolvedVc<Box<dyn EcmascriptChunkPlaceable>>, exported_module: ResolvedVc<Box<dyn EcmascriptChunkPlaceable>>,
referenced_output_assets: ResolvedVc<OutputAssets>,
references: ResolvedVc<OutputAssetsReferences>, references: ResolvedVc<OutputAssetsReferences>,
module_graph: ResolvedVc<ModuleGraph>, module_graph: ResolvedVc<ModuleGraph>,
chunking_context: ResolvedVc<NodeJsChunkingContext>, chunking_context: ResolvedVc<NodeJsChunkingContext>,
...@@ -54,7 +52,6 @@ impl EcmascriptBuildNodeEntryChunk { ...@@ -54,7 +52,6 @@ impl EcmascriptBuildNodeEntryChunk {
other_chunks, other_chunks,
evaluatable_assets, evaluatable_assets,
exported_module, exported_module,
referenced_output_assets,
references, references,
module_graph, module_graph,
chunking_context, chunking_context,
...@@ -192,7 +189,6 @@ impl OutputAssetsReference for EcmascriptBuildNodeEntryChunk { ...@@ -192,7 +189,6 @@ impl OutputAssetsReference for EcmascriptBuildNodeEntryChunk {
Ok(OutputAssetsWithReferenced { Ok(OutputAssetsWithReferenced {
assets: ResolvedVc::cell(assets), assets: ResolvedVc::cell(assets),
referenced_assets: this.referenced_output_assets,
references: this.references, references: this.references,
} }
.cell()) .cell())
......
...@@ -50,7 +50,10 @@ use turbopack_core::{ ...@@ -50,7 +50,10 @@ use turbopack_core::{
chunk_group_info::{ChunkGroup, ChunkGroupEntry}, chunk_group_info::{ChunkGroup, ChunkGroupEntry},
export_usage::compute_export_usage_info, export_usage::compute_export_usage_info,
}, },
output::{OutputAsset, OutputAssets, OutputAssetsReference, OutputAssetsWithReferenced}, output::{
OutputAsset, OutputAssets, OutputAssetsReference, OutputAssetsReferences,
OutputAssetsWithReferenced,
},
reference_type::{EntryReferenceSubType, ReferenceType}, reference_type::{EntryReferenceSubType, ReferenceType},
source::Source, source::Source,
}; };
...@@ -536,13 +539,12 @@ async fn run_test_operation(resource: RcStr) -> Result<Vc<FileSystemPath>> { ...@@ -536,13 +539,12 @@ async fn run_test_operation(resource: RcStr) -> Result<Vc<FileSystemPath>> {
evaluatable_assets, evaluatable_assets,
module_graph, module_graph,
OutputAssets::empty(), OutputAssets::empty(),
OutputAssets::empty(), OutputAssetsReferences::empty(),
AvailabilityInfo::root(), AvailabilityInfo::root(),
) )
.await? .await?
.asset, .asset,
]), ]),
referenced_assets: ResolvedVc::cell(vec![]),
references: ResolvedVc::cell(vec![]), references: ResolvedVc::cell(vec![]),
} }
.cell() .cell()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment