Unverified Commit fa57e47f authored by Tobias Koppers's avatar Tobias Koppers Committed by GitHub

[Turbopack] avoid attaching referenced output assets to chunks (#75933)

### What?

`referenced_output_assets` are different for every chunk group. Attaching them as references to a random chunk in the group causes a different Chunk instance which not only causes duplicate work, but also multiple writes to the same file.

This fixes that by refactoring that and attaching the `referenced_output_assets`  higher. Actually it simplifies it.

Closes PACK-4322
Closes PACK-4392
parent 7ff17dd1
This diff is collapsed.
...@@ -68,7 +68,7 @@ pub(crate) async fn collect_next_dynamic_chunks( ...@@ -68,7 +68,7 @@ pub(crate) async fn collect_next_dynamic_chunks(
.client_component_client_chunks .client_component_client_chunks
.get(&parent_client_reference.unwrap()) .get(&parent_client_reference.unwrap())
.unwrap() .unwrap()
.1 .availability_info
} }
NextDynamicChunkAvailability::AvailabilityInfo(availability_info) => { NextDynamicChunkAvailability::AvailabilityInfo(availability_info) => {
*availability_info *availability_info
......
...@@ -20,7 +20,7 @@ use turbopack_core::{ ...@@ -20,7 +20,7 @@ use turbopack_core::{
GraphEntries, GraphEntries,
chunk_group_info::{ChunkGroup, ChunkGroupEntry}, chunk_group_info::{ChunkGroup, ChunkGroupEntry},
}, },
output::{OutputAsset, OutputAssets}, output::{OutputAsset, OutputAssets, OutputAssetsWithReferenced},
reference_type::{EntryReferenceSubType, ReferenceType}, reference_type::{EntryReferenceSubType, ReferenceType},
source::Source, source::Source,
virtual_output::VirtualOutputAsset, virtual_output::VirtualOutputAsset,
...@@ -97,21 +97,19 @@ impl InstrumentationEndpoint { ...@@ -97,21 +97,19 @@ impl InstrumentationEndpoint {
} }
#[turbo_tasks::function] #[turbo_tasks::function]
async fn edge_files(self: Vc<Self>) -> Result<Vc<OutputAssets>> { async fn edge_chunk_group(self: Vc<Self>) -> Result<Vc<OutputAssetsWithReferenced>> {
let this = self.await?; let this = self.await?;
let module = self.core_modules().await?.edge_entry_module; let module = self.core_modules().await?.edge_entry_module;
let module_graph = this.project.module_graph(*module); let module_graph = this.project.module_graph(*module);
let edge_chunking_context = this.project.edge_chunking_context(false); let edge_chunking_context = this.project.edge_chunking_context(false);
let edge_files: Vc<OutputAssets> = edge_chunking_context.evaluated_chunk_group_assets( Ok(edge_chunking_context.evaluated_chunk_group_assets(
module.ident(), module.ident(),
ChunkGroup::Entry(vec![module]), ChunkGroup::Entry(vec![module]),
module_graph, module_graph,
AvailabilityInfo::Root, AvailabilityInfo::Root,
); ))
Ok(edge_files)
} }
#[turbo_tasks::function] #[turbo_tasks::function]
...@@ -136,6 +134,7 @@ impl InstrumentationEndpoint { ...@@ -136,6 +134,7 @@ impl InstrumentationEndpoint {
Vc::cell(vec![module]), Vc::cell(vec![module]),
module_graph, module_graph,
OutputAssets::empty(), OutputAssets::empty(),
OutputAssets::empty(),
AvailabilityInfo::Root, AvailabilityInfo::Root,
) )
.await?; .await?;
...@@ -147,19 +146,20 @@ impl InstrumentationEndpoint { ...@@ -147,19 +146,20 @@ impl InstrumentationEndpoint {
let this = self.await?; let this = self.await?;
if this.is_edge { if this.is_edge {
let edge_files = self.edge_files(); let edge_chunk_group = self.edge_chunk_group();
let mut output_assets = edge_files.owned().await?; let edge_all_assets = edge_chunk_group.all_assets();
let node_root = this.project.node_root().owned().await?; let node_root = this.project.node_root().owned().await?;
let node_root_value = node_root.clone(); let node_root_value = node_root.clone();
let file_paths_from_root = let file_paths_from_root =
get_js_paths_from_root(&node_root_value, &output_assets).await?; get_js_paths_from_root(&node_root_value, &edge_chunk_group.await?.assets.await?)
.await?;
let all_output_assets = all_assets_from_entries(edge_files).await?; let mut output_assets = all_assets_from_entries(edge_all_assets).owned().await?;
let wasm_paths_from_root = let wasm_paths_from_root =
get_wasm_paths_from_root(&node_root_value, &all_output_assets).await?; get_wasm_paths_from_root(&node_root_value, &output_assets).await?;
let instrumentation_definition = InstrumentationDefinition { let instrumentation_definition = InstrumentationDefinition {
files: file_paths_from_root, files: file_paths_from_root,
......
...@@ -26,7 +26,7 @@ use turbopack_core::{ ...@@ -26,7 +26,7 @@ use turbopack_core::{
GraphEntries, GraphEntries,
chunk_group_info::{ChunkGroup, ChunkGroupEntry}, chunk_group_info::{ChunkGroup, ChunkGroupEntry},
}, },
output::{OutputAsset, OutputAssets}, output::{OutputAsset, OutputAssets, OutputAssetsWithReferenced},
reference_type::{EntryReferenceSubType, ReferenceType}, reference_type::{EntryReferenceSubType, ReferenceType},
source::Source, source::Source,
virtual_output::VirtualOutputAsset, virtual_output::VirtualOutputAsset,
...@@ -104,20 +104,20 @@ impl MiddlewareEndpoint { ...@@ -104,20 +104,20 @@ impl MiddlewareEndpoint {
} }
#[turbo_tasks::function] #[turbo_tasks::function]
async fn edge_files(self: Vc<Self>) -> Result<Vc<OutputAssets>> { async fn edge_chunk_group(self: Vc<Self>) -> Result<Vc<OutputAssetsWithReferenced>> {
let this = self.await?; let this = self.await?;
let module = self.entry_module().to_resolved().await?; let module = self.entry_module().to_resolved().await?;
let module_graph = this.project.module_graph(*module); let module_graph = this.project.module_graph(*module);
let edge_chunking_context = this.project.edge_chunking_context(false); let edge_chunking_context = this.project.edge_chunking_context(false);
let edge_files = edge_chunking_context.evaluated_chunk_group_assets( let edge_chunk_grou = edge_chunking_context.evaluated_chunk_group_assets(
module.ident(), module.ident(),
ChunkGroup::Entry(vec![module]), ChunkGroup::Entry(vec![module]),
module_graph, module_graph,
AvailabilityInfo::Root, AvailabilityInfo::Root,
); );
Ok(edge_files) Ok(edge_chunk_grou)
} }
#[turbo_tasks::function] #[turbo_tasks::function]
...@@ -142,6 +142,7 @@ impl MiddlewareEndpoint { ...@@ -142,6 +142,7 @@ impl MiddlewareEndpoint {
Vc::cell(vec![module]), Vc::cell(vec![module]),
module_graph, module_graph,
OutputAssets::empty(), OutputAssets::empty(),
OutputAssets::empty(),
AvailabilityInfo::Root, AvailabilityInfo::Root,
) )
.await?; .await?;
...@@ -254,22 +255,22 @@ impl MiddlewareEndpoint { ...@@ -254,22 +255,22 @@ impl MiddlewareEndpoint {
Ok(Vc::cell(output_assets)) Ok(Vc::cell(output_assets))
} else { } else {
let edge_files = self.edge_files(); let edge_chunk_group = self.edge_chunk_group();
let mut output_assets = edge_files.owned().await?; let edge_all_assets = edge_chunk_group.all_assets();
let node_root = this.project.node_root().owned().await?; let node_root = this.project.node_root().owned().await?;
let node_root_value = node_root.clone(); let node_root_value = node_root.clone();
let file_paths_from_root = let file_paths_from_root =
get_js_paths_from_root(&node_root_value, &output_assets).await?; get_js_paths_from_root(&node_root_value, &edge_chunk_group.await?.assets.await?)
.await?;
let all_output_assets = all_assets_from_entries(edge_files).await?; let mut output_assets = all_assets_from_entries(edge_all_assets).owned().await?;
let wasm_paths_from_root = let wasm_paths_from_root =
get_wasm_paths_from_root(&node_root_value, &all_output_assets).await?; get_wasm_paths_from_root(&node_root_value, &output_assets).await?;
let all_assets = let all_assets = get_asset_paths_from_root(&node_root_value, &output_assets).await?;
get_asset_paths_from_root(&node_root_value, &all_output_assets).await?;
let regions = if let Some(regions) = config.preferred_region.as_ref() { let regions = if let Some(regions) = config.preferred_region.as_ref() {
if regions.len() == 1 { if regions.len() == 1 {
......
...@@ -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, OutputAssetsWithReferenced},
reference_type::{EcmaScriptModulesReferenceSubType, EntryReferenceSubType, ReferenceType}, reference_type::{EcmaScriptModulesReferenceSubType, EntryReferenceSubType, ReferenceType},
resolve::{origin::PlainResolveOrigin, parse::Request, pattern::Pattern}, resolve::{origin::PlainResolveOrigin, parse::Request, pattern::Pattern},
source::Source, source::Source,
...@@ -756,7 +756,7 @@ impl PageEndpoint { ...@@ -756,7 +756,7 @@ impl PageEndpoint {
} }
#[turbo_tasks::function] #[turbo_tasks::function]
async fn client_chunks(self: Vc<Self>) -> Result<Vc<ChunkGroupResult>> { async fn client_chunk_group(self: Vc<Self>) -> Result<Vc<ChunkGroupResult>> {
async move { async move {
let this = self.await?; let this = self.await?;
...@@ -933,7 +933,7 @@ impl PageEndpoint { ...@@ -933,7 +933,7 @@ impl PageEndpoint {
let ssr_module_graph = self.ssr_module_graph(); let ssr_module_graph = self.ssr_module_graph();
let next_dynamic_imports = if let PageEndpointType::Html = this.ty { let next_dynamic_imports = if let PageEndpointType::Html = this.ty {
let client_availability_info = self.client_chunks().await?.availability_info; let client_availability_info = self.client_chunk_group().await?.availability_info;
let client_module_graph = self.client_module_graph(); let client_module_graph = self.client_module_graph();
...@@ -998,6 +998,7 @@ impl PageEndpoint { ...@@ -998,6 +998,7 @@ impl PageEndpoint {
}; };
let mut current_chunks = OutputAssets::empty(); let mut current_chunks = OutputAssets::empty();
let mut current_referenced_assets = OutputAssets::empty();
let mut current_availability_info = AvailabilityInfo::Root; let mut current_availability_info = AvailabilityInfo::Root;
for layout in [document_module, app_module].iter().flatten().copied() { for layout in [document_module, app_module].iter().flatten().copied() {
let span = tracing::trace_span!( let span = tracing::trace_span!(
...@@ -1005,7 +1006,11 @@ impl PageEndpoint { ...@@ -1005,7 +1006,11 @@ impl PageEndpoint {
name = display(layout.ident().to_string().await?) name = display(layout.ident().to_string().await?)
); );
async { async {
let chunk_group = chunking_context let ChunkGroupResult {
assets,
referenced_assets,
availability_info,
} = *chunking_context
.chunk_group( .chunk_group(
layout.ident(), layout.ident(),
ChunkGroup::Shared(layout), ChunkGroup::Shared(layout),
...@@ -1014,11 +1019,12 @@ impl PageEndpoint { ...@@ -1014,11 +1019,12 @@ impl PageEndpoint {
) )
.await?; .await?;
current_chunks = current_chunks current_chunks = current_chunks.concatenate(*assets).resolve().await?;
.concatenate(*chunk_group.assets) current_referenced_assets = current_referenced_assets
.concatenate(*referenced_assets)
.resolve() .resolve()
.await?; .await?;
current_availability_info = chunk_group.availability_info; current_availability_info = availability_info;
anyhow::Ok(()) anyhow::Ok(())
} }
...@@ -1030,15 +1036,27 @@ impl PageEndpoint { ...@@ -1030,15 +1036,27 @@ impl PageEndpoint {
.context("could not process page loader entry module")?; .context("could not process page loader entry module")?;
let is_edge = matches!(runtime, NextRuntime::Edge); let is_edge = matches!(runtime, NextRuntime::Edge);
if is_edge { if is_edge {
let edge_files = edge_chunking_context.evaluated_chunk_group_assets( let OutputAssetsWithReferenced {
ssr_module.ident(), assets: edge_assets,
ChunkGroup::Entry(vec![ResolvedVc::upcast(ssr_module_evaluatable)]), referenced_assets: edge_referenced_assets,
ssr_module_graph, } = *edge_chunking_context
current_availability_info, .evaluated_chunk_group_assets(
); ssr_module.ident(),
ChunkGroup::Entry(vec![ResolvedVc::upcast(ssr_module_evaluatable)]),
ssr_module_graph,
current_availability_info,
)
.await?;
Ok(SsrChunk::Edge { Ok(SsrChunk::Edge {
files: current_chunks.concatenate(edge_files).to_resolved().await?, assets: current_chunks
.concatenate(*edge_assets)
.to_resolved()
.await?,
referenced_assets: current_referenced_assets
.concatenate(*edge_referenced_assets)
.to_resolved()
.await?,
dynamic_import_entries, dynamic_import_entries,
regions: regions.clone(), regions: regions.clone(),
} }
...@@ -1056,6 +1074,7 @@ impl PageEndpoint { ...@@ -1056,6 +1074,7 @@ impl PageEndpoint {
EvaluatableAssets::empty().with_entry(*ssr_module_evaluatable), EvaluatableAssets::empty().with_entry(*ssr_module_evaluatable),
ssr_module_graph, ssr_module_graph,
current_chunks, current_chunks,
current_referenced_assets,
current_availability_info, current_availability_info,
) )
.to_resolved() .to_resolved()
...@@ -1296,8 +1315,16 @@ impl PageEndpoint { ...@@ -1296,8 +1315,16 @@ impl PageEndpoint {
let ssr_chunk = match this.ty { let ssr_chunk = match this.ty {
PageEndpointType::Html => { PageEndpointType::Html => {
let client_chunks = *self.client_chunks().await?.assets; let client_chunk_group = self.client_chunk_group().await?;
let client_chunks = *client_chunk_group.assets;
client_assets.extend(client_chunks.await?.iter().map(|asset| **asset)); client_assets.extend(client_chunks.await?.iter().map(|asset| **asset));
client_assets.extend(
client_chunk_group
.referenced_assets
.await?
.iter()
.map(|asset| **asset),
);
let build_manifest = self.build_manifest(client_chunks).to_resolved().await?; let build_manifest = self.build_manifest(client_chunks).to_resolved().await?;
let page_loader = self.page_loader(client_chunks); let page_loader = self.page_loader(client_chunks);
...@@ -1394,7 +1421,8 @@ impl PageEndpoint { ...@@ -1394,7 +1421,8 @@ impl PageEndpoint {
} }
} }
SsrChunk::Edge { SsrChunk::Edge {
files, assets,
referenced_assets,
dynamic_import_entries, dynamic_import_entries,
ref regions, ref regions,
} => { } => {
...@@ -1414,9 +1442,14 @@ impl PageEndpoint { ...@@ -1414,9 +1442,14 @@ impl PageEndpoint {
fxindexset![] fxindexset![]
}; };
let files_value = files.await?; let all_assets = assets.concatenate(*referenced_assets);
let assets_ref = assets.await?;
server_assets.extend(referenced_assets.await?.iter().copied());
if let Some(&file) = files_value.first() { // TODO(sokra): accessing the 1st asset is a bit hacky, we should find a better
// way to get the main entry asset
if let Some(&file) = assets_ref.first() {
let pages_manifest = self.pages_manifest(*file).to_resolved().await?; let pages_manifest = self.pages_manifest(*file).to_resolved().await?;
server_assets.push(pages_manifest); server_assets.push(pages_manifest);
} }
...@@ -1424,9 +1457,9 @@ impl PageEndpoint { ...@@ -1424,9 +1457,9 @@ impl PageEndpoint {
// Only include the actual edge files if pages should be created // Only include the actual edge files if pages should be created
let pages_structure = this.pages_structure.await?; let pages_structure = this.pages_structure.await?;
if pages_structure.should_create_pages_entries { if pages_structure.should_create_pages_entries {
server_assets.extend(files_value.iter().copied()); server_assets.extend(assets_ref.iter().copied());
file_paths_from_root file_paths_from_root
.extend(get_js_paths_from_root(&node_root, &files_value).await?); .extend(get_js_paths_from_root(&node_root, &assets_ref).await?);
} }
if emit_manifests == EmitManifests::Full { if emit_manifests == EmitManifests::Full {
...@@ -1444,7 +1477,7 @@ impl PageEndpoint { ...@@ -1444,7 +1477,7 @@ impl PageEndpoint {
let (wasm_paths_from_root, all_assets) = let (wasm_paths_from_root, all_assets) =
if pages_structure.should_create_pages_entries { if pages_structure.should_create_pages_entries {
let all_output_assets = all_assets_from_entries(*files).await?; let all_output_assets = all_assets_from_entries(all_assets).await?;
let mut wasm_paths_from_root = fxindexset![]; let mut wasm_paths_from_root = fxindexset![];
wasm_paths_from_root.extend( wasm_paths_from_root.extend(
...@@ -1512,7 +1545,7 @@ impl PageEndpoint { ...@@ -1512,7 +1545,7 @@ impl PageEndpoint {
} }
PageEndpointOutput::Edge { PageEndpointOutput::Edge {
files, files: assets,
server_assets: ResolvedVc::cell(server_assets), server_assets: ResolvedVc::cell(server_assets),
client_assets, client_assets,
} }
...@@ -1745,7 +1778,8 @@ pub enum SsrChunk { ...@@ -1745,7 +1778,8 @@ pub enum SsrChunk {
server_asset_trace_file: ResolvedVc<OptionOutputAsset>, server_asset_trace_file: ResolvedVc<OptionOutputAsset>,
}, },
Edge { Edge {
files: ResolvedVc<OutputAssets>, assets: ResolvedVc<OutputAssets>,
referenced_assets: ResolvedVc<OutputAssets>,
dynamic_import_entries: ResolvedVc<DynamicImportedChunks>, dynamic_import_entries: ResolvedVc<DynamicImportedChunks>,
regions: Option<Vec<RcStr>>, regions: Option<Vec<RcStr>>,
}, },
......
...@@ -3,10 +3,10 @@ use tracing::Instrument; ...@@ -3,10 +3,10 @@ use tracing::Instrument;
use turbo_rcstr::rcstr; use turbo_rcstr::rcstr;
use turbo_tasks::{FxIndexMap, ResolvedVc, TryFlatJoinIterExt, TryJoinIterExt, Vc}; use turbo_tasks::{FxIndexMap, ResolvedVc, TryFlatJoinIterExt, TryJoinIterExt, Vc};
use turbopack_core::{ use turbopack_core::{
chunk::{ChunkingContext, availability_info::AvailabilityInfo}, chunk::{ChunkGroupResult, ChunkingContext, availability_info::AvailabilityInfo},
module::Module, module::Module,
module_graph::{ModuleGraph, chunk_group_info::ChunkGroup}, module_graph::{ModuleGraph, chunk_group_info::ChunkGroup},
output::OutputAssets, output::{OutputAssets, OutputAssetsWithReferenced},
}; };
use crate::{ use crate::{
...@@ -22,12 +22,10 @@ use crate::{ ...@@ -22,12 +22,10 @@ use crate::{
#[turbo_tasks::value] #[turbo_tasks::value]
pub struct ClientReferencesChunks { pub struct ClientReferencesChunks {
pub client_component_client_chunks: pub client_component_client_chunks: FxIndexMap<ClientReferenceType, ChunkGroupResult>,
FxIndexMap<ClientReferenceType, (ResolvedVc<OutputAssets>, AvailabilityInfo)>, pub client_component_ssr_chunks: FxIndexMap<ClientReferenceType, ChunkGroupResult>,
pub client_component_ssr_chunks:
FxIndexMap<ClientReferenceType, (ResolvedVc<OutputAssets>, AvailabilityInfo)>,
pub layout_segment_client_chunks: pub layout_segment_client_chunks:
FxIndexMap<ResolvedVc<NextServerComponentModule>, ResolvedVc<OutputAssets>>, FxIndexMap<ResolvedVc<NextServerComponentModule>, OutputAssetsWithReferenced>,
} }
/// Computes all client references chunks. /// Computes all client references chunks.
...@@ -161,8 +159,10 @@ pub async fn get_app_client_references_chunks( ...@@ -161,8 +159,10 @@ pub async fn get_app_client_references_chunks(
let mut current_client_availability_info = client_availability_info; let mut current_client_availability_info = client_availability_info;
let mut current_client_chunks = OutputAssets::empty().to_resolved().await?; let mut current_client_chunks = OutputAssets::empty().to_resolved().await?;
let mut current_client_referenced_assets = OutputAssets::empty().to_resolved().await?;
let mut current_ssr_availability_info = AvailabilityInfo::Root; let mut current_ssr_availability_info = AvailabilityInfo::Root;
let mut current_ssr_chunks = OutputAssets::empty().to_resolved().await?; let mut current_ssr_chunks = OutputAssets::empty().to_resolved().await?;
let mut current_ssr_referenced_assets = OutputAssets::empty().to_resolved().await?;
let mut layout_segment_client_chunks = FxIndexMap::default(); let mut layout_segment_client_chunks = FxIndexMap::default();
let mut client_component_ssr_chunks = FxIndexMap::default(); let mut client_component_ssr_chunks = FxIndexMap::default();
...@@ -264,18 +264,34 @@ pub async fn get_app_client_references_chunks( ...@@ -264,18 +264,34 @@ pub async fn get_app_client_references_chunks(
}; };
if let Some(client_chunk_group) = client_chunk_group { if let Some(client_chunk_group) = client_chunk_group {
let client_chunk_group = client_chunk_group.await?; let ChunkGroupResult {
assets,
referenced_assets,
availability_info,
} = *client_chunk_group.await?;
let client_chunks = let client_chunks = current_client_chunks
current_client_chunks.concatenate(*client_chunk_group.assets); .concatenate(*assets)
let client_chunks = client_chunks.to_resolved().await?; .to_resolved()
.await?;
let client_referenced_assets = current_client_referenced_assets
.concatenate(*referenced_assets)
.to_resolved()
.await?;
if is_layout { if is_layout {
current_client_availability_info = client_chunk_group.availability_info; current_client_availability_info = availability_info;
current_client_chunks = client_chunks; current_client_chunks = client_chunks;
current_client_referenced_assets = client_referenced_assets;
} }
layout_segment_client_chunks.insert(server_component, client_chunks); layout_segment_client_chunks.insert(
server_component,
OutputAssetsWithReferenced {
assets: client_chunks,
referenced_assets: client_referenced_assets,
},
);
for &client_reference_ty in client_reference_types.iter() { for &client_reference_ty in client_reference_types.iter() {
if let ClientReferenceType::EcmascriptClientReference(_) = if let ClientReferenceType::EcmascriptClientReference(_) =
...@@ -283,7 +299,11 @@ pub async fn get_app_client_references_chunks( ...@@ -283,7 +299,11 @@ pub async fn get_app_client_references_chunks(
{ {
client_component_client_chunks.insert( client_component_client_chunks.insert(
client_reference_ty, client_reference_ty,
(client_chunks, client_chunk_group.availability_info), ChunkGroupResult {
assets: client_chunks,
referenced_assets: client_referenced_assets,
availability_info,
},
); );
} }
} }
...@@ -292,12 +312,19 @@ pub async fn get_app_client_references_chunks( ...@@ -292,12 +312,19 @@ pub async fn get_app_client_references_chunks(
if let Some(ssr_chunk_group) = ssr_chunk_group { if let Some(ssr_chunk_group) = ssr_chunk_group {
let ssr_chunk_group = ssr_chunk_group.await?; let ssr_chunk_group = ssr_chunk_group.await?;
let ssr_chunks = current_ssr_chunks.concatenate(*ssr_chunk_group.assets); let ssr_chunks = current_ssr_chunks
let ssr_chunks = ssr_chunks.to_resolved().await?; .concatenate(*ssr_chunk_group.assets)
.to_resolved()
.await?;
let ssr_referenced_assets = current_ssr_referenced_assets
.concatenate(*ssr_chunk_group.referenced_assets)
.to_resolved()
.await?;
if is_layout { if is_layout {
current_ssr_availability_info = ssr_chunk_group.availability_info; current_ssr_availability_info = ssr_chunk_group.availability_info;
current_ssr_chunks = ssr_chunks; current_ssr_chunks = ssr_chunks;
current_ssr_referenced_assets = ssr_referenced_assets;
} }
for &client_reference_ty in client_reference_types.iter() { for &client_reference_ty in client_reference_types.iter() {
...@@ -306,7 +333,11 @@ pub async fn get_app_client_references_chunks( ...@@ -306,7 +333,11 @@ pub async fn get_app_client_references_chunks(
{ {
client_component_ssr_chunks.insert( client_component_ssr_chunks.insert(
client_reference_ty, client_reference_ty,
(ssr_chunks, ssr_chunk_group.availability_info), ChunkGroupResult {
assets: ssr_chunks,
referenced_assets: ssr_referenced_assets,
availability_info: ssr_chunk_group.availability_info,
},
); );
} }
} }
......
...@@ -20,6 +20,7 @@ pub async fn get_app_client_shared_chunk_group( ...@@ -20,6 +20,7 @@ pub async fn get_app_client_shared_chunk_group(
if app_client_runtime_entries.await?.is_empty() { if app_client_runtime_entries.await?.is_empty() {
return Ok(ChunkGroupResult { return Ok(ChunkGroupResult {
assets: OutputAssets::empty().to_resolved().await?, assets: OutputAssets::empty().to_resolved().await?,
referenced_assets: OutputAssets::empty().to_resolved().await?,
availability_info: AvailabilityInfo::Root, availability_info: AvailabilityInfo::Root,
} }
.cell()); .cell());
......
...@@ -13,9 +13,11 @@ use turbo_tasks::{ ...@@ -13,9 +13,11 @@ use turbo_tasks::{
use turbo_tasks_fs::{File, FileSystemPath}; use turbo_tasks_fs::{File, FileSystemPath};
use turbopack_core::{ use turbopack_core::{
asset::{Asset, AssetContent}, asset::{Asset, AssetContent},
chunk::{ChunkingContext, ModuleChunkItemIdExt, ModuleId as TurbopackModuleId}, chunk::{
ChunkGroupResult, ChunkingContext, ModuleChunkItemIdExt, ModuleId as TurbopackModuleId,
},
module_graph::async_module_info::AsyncModulesInfo, module_graph::async_module_info::AsyncModulesInfo,
output::OutputAsset, output::{OutputAsset, OutputAssetsWithReferenced},
virtual_output::VirtualOutputAsset, virtual_output::VirtualOutputAsset,
}; };
use turbopack_ecmascript::utils::StringifyJs; use turbopack_ecmascript::utils::StringifyJs;
...@@ -172,44 +174,50 @@ impl ClientReferenceManifest { ...@@ -172,44 +174,50 @@ impl ClientReferenceManifest {
.chunk_item_id(*client_chunking_context) .chunk_item_id(*client_chunking_context)
.await?; .await?;
let (client_chunks_paths, client_is_async) = let (client_chunks_paths, client_is_async) = if let Some(ChunkGroupResult {
if let Some((client_chunks, _client_availability_info)) = assets: client_chunks,
client_component_client_chunks.get(&app_client_reference_ty) referenced_assets: client_referenced_assets,
{ availability_info: _,
let client_chunks = client_chunks.await?; }) =
references.extend(client_chunks.iter()); client_component_client_chunks.get(&app_client_reference_ty)
let client_chunks_paths = cached_chunk_paths( {
&mut client_chunk_path_cache, let client_chunks = client_chunks.await?;
client_chunks.iter().copied(), let client_referenced_assets = client_referenced_assets.await?;
) references.extend(client_chunks.iter());
.await?; references.extend(client_referenced_assets.iter());
let client_chunks_paths = cached_chunk_paths(
&mut client_chunk_path_cache,
client_chunks.iter().copied(),
)
.await?;
let chunk_paths = client_chunks_paths let chunk_paths = client_chunks_paths
.filter_map(|(_, chunk_path)| { .filter_map(|(_, chunk_path)| {
client_relative_path client_relative_path
.get_path_to(&chunk_path) .get_path_to(&chunk_path)
.map(ToString::to_string) .map(ToString::to_string)
}) })
// It's possible that a chunk also emits CSS files, that will // It's possible that a chunk also emits CSS files, that will
// be handled separately. // be handled separately.
.filter(|path| path.ends_with(".js")) .filter(|path| path.ends_with(".js"))
.map(|path| { .map(|path| {
format!( format!(
"{}{}{}", "{}{}{}",
prefix_path, prefix_path,
path.split('/').map(encode_uri_component).format("/"), path.split('/').map(encode_uri_component).format("/"),
suffix_path suffix_path
) )
}) })
.map(RcStr::from) .map(RcStr::from)
.collect::<Vec<_>>(); .collect::<Vec<_>>();
let is_async = async_modules.contains(&ResolvedVc::upcast(client_module)); let is_async = async_modules.contains(&ResolvedVc::upcast(client_module));
(chunk_paths, is_async) (chunk_paths, is_async)
} else { } else {
(Vec::new(), false) (Vec::new(), false)
}; };
if let Some(ssr_chunking_context) = ssr_chunking_context { if let Some(ssr_chunking_context) = ssr_chunking_context {
let ssr_module = client_reference_module_ref.ssr_module; let ssr_module = client_reference_module_ref.ssr_module;
...@@ -225,11 +233,16 @@ impl ClientReferenceManifest { ...@@ -225,11 +233,16 @@ impl ClientReferenceManifest {
// edge runtime doesn't support dynamically // edge runtime doesn't support dynamically
// loading chunks. // loading chunks.
(Vec::new(), false) (Vec::new(), false)
} else if let Some((ssr_chunks, _ssr_availability_info)) = } else if let Some(ChunkGroupResult {
client_component_ssr_chunks.get(&app_client_reference_ty) assets: ssr_chunks,
referenced_assets: ssr_referenced_assets,
availability_info: _,
}) = client_component_ssr_chunks.get(&app_client_reference_ty)
{ {
let ssr_chunks = ssr_chunks.await?; let ssr_chunks = ssr_chunks.await?;
let ssr_referenced_assets = ssr_referenced_assets.await?;
references.extend(ssr_chunks.iter()); references.extend(ssr_chunks.iter());
references.extend(ssr_referenced_assets.iter());
let ssr_chunks_paths = cached_chunk_paths( let ssr_chunks_paths = cached_chunk_paths(
&mut ssr_chunk_path_cache, &mut ssr_chunk_path_cache,
...@@ -317,7 +330,14 @@ impl ClientReferenceManifest { ...@@ -317,7 +330,14 @@ impl ClientReferenceManifest {
} }
// per layout segment chunks need to be emitted into the manifest too // per layout segment chunks need to be emitted into the manifest too
for (server_component, client_chunks) in layout_segment_client_chunks.iter() { for (
server_component,
OutputAssetsWithReferenced {
assets: client_chunks,
referenced_assets: _,
},
) in layout_segment_client_chunks.iter()
{
let server_component_name = server_component let server_component_name = server_component
.server_path() .server_path()
.await? .await?
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
"moduleResolution": "bundler", "moduleResolution": "bundler",
"resolveJsonModule": true, "resolveJsonModule": true,
"isolatedModules": true, "isolatedModules": true,
"jsx": "preserve", "jsx": "react-jsx",
"plugins": [ "plugins": [
{ {
"name": "next" "name": "next"
...@@ -21,6 +21,12 @@ ...@@ -21,6 +21,12 @@
"strictNullChecks": true, "strictNullChecks": true,
"target": "ES2017" "target": "ES2017"
}, },
"include": ["next-env.d.ts", ".next/types/**/*.ts", "**/*.ts", "**/*.tsx"], "include": [
"exclude": ["node_modules"] "**/*.ts",
"**/*.tsx",
".next/types/**/*.ts",
"next-env.d.ts",
"**/*.mts"
],
"exclude": ["node_modules", "**/*.test.ts", "**/*.test.tsx"]
} }
import { nextTestSetup } from 'e2e-utils' import { nextTestSetup } from 'e2e-utils'
import { check } from 'next-test-utils' import { retry } from 'next-test-utils'
import { join } from 'node:path' import { join } from 'node:path'
describe('deployment-id-handling disabled', () => { describe('deployment-id-handling disabled', () => {
...@@ -62,10 +62,7 @@ describe('deployment-id-handling disabled', () => { ...@@ -62,10 +62,7 @@ describe('deployment-id-handling disabled', () => {
await browser.elementByCss('#dynamic-import').click() await browser.elementByCss('#dynamic-import').click()
await check( await retry(() => expect(requests).not.toBeEmpty())
() => (requests.length > 0 ? 'success' : JSON.stringify(requests)),
'success'
)
try { try {
expect( expect(
......
import { nextTestSetup } from 'e2e-utils' import { nextTestSetup } from 'e2e-utils'
import { check, retry } from 'next-test-utils' import { retry } from 'next-test-utils'
import { join } from 'node:path' import { join } from 'node:path'
describe.each(['NEXT_DEPLOYMENT_ID', 'CUSTOM_DEPLOYMENT_ID'])( describe.each(['NEXT_DEPLOYMENT_ID', 'CUSTOM_DEPLOYMENT_ID'])(
...@@ -58,10 +58,7 @@ describe.each(['NEXT_DEPLOYMENT_ID', 'CUSTOM_DEPLOYMENT_ID'])( ...@@ -58,10 +58,7 @@ describe.each(['NEXT_DEPLOYMENT_ID', 'CUSTOM_DEPLOYMENT_ID'])(
await browser.elementByCss('#dynamic-import').click() await browser.elementByCss('#dynamic-import').click()
await check( await retry(() => expect(requests).not.toBeEmpty())
() => (requests.length > 0 ? 'success' : JSON.stringify(requests)),
'success'
)
try { try {
expect( expect(
...@@ -190,10 +187,7 @@ describe('deployment-id-handling disabled', () => { ...@@ -190,10 +187,7 @@ describe('deployment-id-handling disabled', () => {
await browser.elementByCss('#dynamic-import').click() await browser.elementByCss('#dynamic-import').click()
await check( await retry(() => expect(requests).not.toBeEmpty())
() => (requests.length > 0 ? 'success' : JSON.stringify(requests)),
'success'
)
try { try {
expect( expect(
......
...@@ -577,6 +577,7 @@ impl ChunkingContext for BrowserChunkingContext { ...@@ -577,6 +577,7 @@ impl ChunkingContext for BrowserChunkingContext {
let input_availability_info = availability_info; let input_availability_info = availability_info;
let MakeChunkGroupResult { let MakeChunkGroupResult {
chunks, chunks,
referenced_output_assets,
availability_info, availability_info,
} = make_chunk_group( } = make_chunk_group(
entries, entries,
...@@ -619,6 +620,7 @@ impl ChunkingContext for BrowserChunkingContext { ...@@ -619,6 +620,7 @@ impl ChunkingContext for BrowserChunkingContext {
Ok(ChunkGroupResult { Ok(ChunkGroupResult {
assets: ResolvedVc::cell(assets), assets: ResolvedVc::cell(assets),
referenced_assets: ResolvedVc::cell(referenced_output_assets),
availability_info, availability_info,
} }
.cell()) .cell())
...@@ -644,6 +646,7 @@ impl ChunkingContext for BrowserChunkingContext { ...@@ -644,6 +646,7 @@ impl ChunkingContext for BrowserChunkingContext {
let entries = chunk_group.entries(); let entries = chunk_group.entries();
let MakeChunkGroupResult { let MakeChunkGroupResult {
chunks, chunks,
referenced_output_assets,
availability_info, availability_info,
} = make_chunk_group( } = make_chunk_group(
entries, entries,
...@@ -703,6 +706,7 @@ impl ChunkingContext for BrowserChunkingContext { ...@@ -703,6 +706,7 @@ impl ChunkingContext for BrowserChunkingContext {
Ok(ChunkGroupResult { Ok(ChunkGroupResult {
assets: ResolvedVc::cell(assets), assets: ResolvedVc::cell(assets),
referenced_assets: ResolvedVc::cell(referenced_output_assets),
availability_info, availability_info,
} }
.cell()) .cell())
...@@ -718,6 +722,7 @@ impl ChunkingContext for BrowserChunkingContext { ...@@ -718,6 +722,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>,
_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")
......
...@@ -23,8 +23,8 @@ use turbopack_cli_utils::issue::{ConsoleUi, LogOptions}; ...@@ -23,8 +23,8 @@ use turbopack_cli_utils::issue::{ConsoleUi, LogOptions};
use turbopack_core::{ use turbopack_core::{
asset::Asset, asset::Asset,
chunk::{ chunk::{
ChunkingConfig, ChunkingContext, EvaluatableAsset, EvaluatableAssets, MangleType, ChunkingConfig, ChunkingContext, ChunkingContextExt, EvaluatableAsset, EvaluatableAssets,
MinifyType, SourceMapsType, availability_info::AvailabilityInfo, MangleType, MinifyType, SourceMapsType, availability_info::AvailabilityInfo,
}, },
environment::{BrowserEnvironment, Environment, ExecutionEnvironment, NodeJsEnvironment}, environment::{BrowserEnvironment, Environment, ExecutionEnvironment, NodeJsEnvironment},
ident::AssetIdent, ident::AssetIdent,
...@@ -35,7 +35,7 @@ use turbopack_core::{ ...@@ -35,7 +35,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}, output::{OutputAsset, OutputAssets, OutputAssetsWithReferenced},
reference::all_assets_from_entries, reference::all_assets_from_entries,
reference_type::{EntryReferenceSubType, ReferenceType}, reference_type::{EntryReferenceSubType, ReferenceType},
resolve::{ resolve::{
...@@ -428,8 +428,8 @@ async fn build_internal( ...@@ -428,8 +428,8 @@ async fn build_internal(
{ {
match target { match target {
Target::Browser => { Target::Browser => {
chunking_context *chunking_context
.evaluated_chunk_group( .evaluated_chunk_group_assets(
AssetIdent::from_path( AssetIdent::from_path(
build_output_root build_output_root
.join( .join(
...@@ -449,29 +449,32 @@ async fn build_internal( ...@@ -449,29 +449,32 @@ async fn build_internal(
AvailabilityInfo::Root, AvailabilityInfo::Root,
) )
.await? .await?
.assets
} }
Target::Node => ResolvedVc::cell(vec![ Target::Node => OutputAssetsWithReferenced {
chunking_context assets: ResolvedVc::cell(vec![
.entry_chunk_group( chunking_context
build_output_root .entry_chunk_group(
.join( build_output_root
ecmascript .join(
.ident() ecmascript
.path() .ident()
.await? .path()
.file_stem() .await?
.unwrap(), .file_stem()
)? .unwrap(),
.with_extension("entry.js"), )?
EvaluatableAssets::one(*ecmascript), .with_extension("entry.js"),
module_graph, EvaluatableAssets::one(*ecmascript),
OutputAssets::empty(), module_graph,
AvailabilityInfo::Root, OutputAssets::empty(),
) OutputAssets::empty(),
.await? AvailabilityInfo::Root,
.asset, )
]), .await?
.asset,
]),
referenced_assets: ResolvedVc::cell(vec![]),
},
} }
} else { } else {
bail!( bail!(
...@@ -485,16 +488,27 @@ async fn build_internal( ...@@ -485,16 +488,27 @@ async fn build_internal(
.try_join() .try_join()
.await?; .await?;
let mut chunks: FxHashSet<ResolvedVc<Box<dyn OutputAsset>>> = FxHashSet::default(); let all_assets = async move {
for chunk_group in entry_chunk_groups { let mut all_assets: FxHashSet<ResolvedVc<Box<dyn OutputAsset>>> = FxHashSet::default();
chunks.extend( for OutputAssetsWithReferenced {
&*async move { all_assets_from_entries(*chunk_group).await } assets,
.instrument(tracing::info_span!("list chunks")) referenced_assets,
.await?, } in entry_chunk_groups
); {
all_assets.extend(all_assets_from_entries(*assets).await?.into_iter().copied());
all_assets.extend(
all_assets_from_entries(*referenced_assets)
.await?
.into_iter()
.copied(),
);
}
anyhow::Ok(all_assets)
} }
.instrument(tracing::info_span!("list chunks"))
.await?;
chunks all_assets
.iter() .iter()
.map(|c| async move { c.content().write(c.path().owned().await?).await }) .map(|c| async move { c.content().write(c.path().owned().await?).await })
.try_join() .try_join()
......
...@@ -25,13 +25,14 @@ use crate::{ ...@@ -25,13 +25,14 @@ use crate::{
}, },
module_batches::{BatchingConfig, ModuleBatchesGraphEdge}, module_batches::{BatchingConfig, ModuleBatchesGraphEdge},
}, },
output::OutputAssets, output::{OutputAsset, OutputAssets},
reference::ModuleReference, reference::ModuleReference,
traced_asset::TracedAsset, traced_asset::TracedAsset,
}; };
pub struct MakeChunkGroupResult { pub struct MakeChunkGroupResult {
pub chunks: Vec<ResolvedVc<Box<dyn Chunk>>>, pub chunks: Vec<ResolvedVc<Box<dyn Chunk>>>,
pub referenced_output_assets: Vec<ResolvedVc<Box<dyn OutputAsset>>>,
pub availability_info: AvailabilityInfo, pub availability_info: AvailabilityInfo,
} }
...@@ -155,12 +156,12 @@ pub async fn make_chunk_group( ...@@ -155,12 +156,12 @@ pub async fn make_chunk_group(
chunk_items, chunk_items,
chunk_item_batch_groups, chunk_item_batch_groups,
rcstr!(""), rcstr!(""),
ResolvedVc::cell(referenced_output_assets),
) )
.await?; .await?;
Ok(MakeChunkGroupResult { Ok(MakeChunkGroupResult {
chunks, chunks,
referenced_output_assets,
availability_info, availability_info,
}) })
} }
......
use std::{future::IntoFuture, mem::replace}; use std::future::IntoFuture;
use anyhow::Result; use anyhow::Result;
use rustc_hash::FxHashMap; use rustc_hash::FxHashMap;
...@@ -26,7 +26,6 @@ use crate::{ ...@@ -26,7 +26,6 @@ use crate::{
}, },
}, },
module_graph::ModuleGraph, module_graph::ModuleGraph,
output::OutputAssets,
}; };
mod dev; mod dev;
...@@ -283,15 +282,13 @@ async fn batch_chunk_items_with_info_with_type( ...@@ -283,15 +282,13 @@ async fn batch_chunk_items_with_info_with_type(
Ok(Vc::cell(map)) Ok(Vc::cell(map))
} }
/// Creates chunks based on heuristics for the passed `chunk_items`. Also /// Creates chunks based on heuristics for the passed `chunk_items`.
/// attaches `referenced_output_assets` to the first chunk.
pub async fn make_chunks( pub async fn make_chunks(
module_graph: Vc<ModuleGraph>, module_graph: Vc<ModuleGraph>,
chunking_context: ResolvedVc<Box<dyn ChunkingContext>>, chunking_context: ResolvedVc<Box<dyn ChunkingContext>>,
chunk_items_or_batches: Vec<ChunkItemOrBatchWithAsyncModuleInfo>, chunk_items_or_batches: Vec<ChunkItemOrBatchWithAsyncModuleInfo>,
batch_groups: Vec<ResolvedVc<ChunkItemBatchGroup>>, batch_groups: Vec<ResolvedVc<ChunkItemBatchGroup>>,
key_prefix: RcStr, key_prefix: RcStr,
mut referenced_output_assets: ResolvedVc<OutputAssets>,
) -> Result<Vec<ResolvedVc<Box<dyn Chunk>>>> { ) -> Result<Vec<ResolvedVc<Box<dyn Chunk>>>> {
let chunking_configs = &*chunking_context.chunking_configs().await?; let chunking_configs = &*chunking_context.chunking_configs().await?;
...@@ -330,8 +327,6 @@ pub async fn make_chunks( ...@@ -330,8 +327,6 @@ pub async fn make_chunks(
ty, ty,
chunking_context, chunking_context,
chunks: &mut chunks, chunks: &mut chunks,
referenced_output_assets: &mut referenced_output_assets,
empty_referenced_output_assets: OutputAssets::empty().to_resolved().await?,
}; };
if let Some(chunking_config) = chunking_configs.get(&ty) { if let Some(chunking_config) = chunking_configs.get(&ty) {
...@@ -400,8 +395,6 @@ struct SplitContext<'a> { ...@@ -400,8 +395,6 @@ struct SplitContext<'a> {
// resolution of `chunks` is deferred so it can be done with `try_join` at the end, letting as // resolution of `chunks` is deferred so it can be done with `try_join` at the end, letting as
// much work happen in parallel as possible. // much work happen in parallel as possible.
chunks: &'a mut Vec<Vc<Box<dyn Chunk>>>, chunks: &'a mut Vec<Vc<Box<dyn Chunk>>>,
referenced_output_assets: &'a mut ResolvedVc<OutputAssets>,
empty_referenced_output_assets: ResolvedVc<OutputAssets>,
} }
/// Creates a chunk with the given `chunk_items. `key` should be unique. /// Creates a chunk with the given `chunk_items. `key` should be unique.
...@@ -427,10 +420,6 @@ async fn make_chunk<'l>( ...@@ -427,10 +420,6 @@ async fn make_chunk<'l>(
}) })
.collect(), .collect(),
ResolvedVc::deref_vec(batch_groups), ResolvedVc::deref_vec(batch_groups),
*replace(
split_context.referenced_output_assets,
split_context.empty_referenced_output_assets,
),
), ),
); );
Ok(()) Ok(())
......
...@@ -17,7 +17,7 @@ use crate::{ ...@@ -17,7 +17,7 @@ use crate::{
ModuleGraph, chunk_group_info::ChunkGroup, export_usage::ModuleExportUsage, ModuleGraph, chunk_group_info::ChunkGroup, export_usage::ModuleExportUsage,
module_batches::BatchingConfig, module_batches::BatchingConfig,
}, },
output::{OutputAsset, OutputAssets}, output::{OutputAsset, OutputAssets, OutputAssetsWithReferenced},
}; };
#[derive( #[derive(
...@@ -87,8 +87,10 @@ pub enum ChunkGroupType { ...@@ -87,8 +87,10 @@ pub enum ChunkGroupType {
} }
#[turbo_tasks::value(shared)] #[turbo_tasks::value(shared)]
#[derive(Clone, Copy)]
pub struct ChunkGroupResult { pub struct ChunkGroupResult {
pub assets: ResolvedVc<OutputAssets>, pub assets: ResolvedVc<OutputAssets>,
pub referenced_assets: ResolvedVc<OutputAssets>,
pub availability_info: AvailabilityInfo, pub availability_info: AvailabilityInfo,
} }
...@@ -273,6 +275,7 @@ pub trait ChunkingContext { ...@@ -273,6 +275,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>,
availability_info: AvailabilityInfo, availability_info: AvailabilityInfo,
) -> Result<Vc<EntryChunkGroupResult>>; ) -> Result<Vc<EntryChunkGroupResult>>;
...@@ -313,7 +316,7 @@ pub trait ChunkingContextExt { ...@@ -313,7 +316,7 @@ pub trait ChunkingContextExt {
ident: Vc<AssetIdent>, ident: Vc<AssetIdent>,
chunk_group: ChunkGroup, chunk_group: ChunkGroup,
module_graph: Vc<ModuleGraph>, module_graph: Vc<ModuleGraph>,
) -> Vc<OutputAssets> ) -> Vc<OutputAssetsWithReferenced>
where where
Self: Send; Self: Send;
...@@ -323,7 +326,7 @@ pub trait ChunkingContextExt { ...@@ -323,7 +326,7 @@ pub trait ChunkingContextExt {
chunk_group: ChunkGroup, chunk_group: ChunkGroup,
module_graph: Vc<ModuleGraph>, module_graph: Vc<ModuleGraph>,
availability_info: AvailabilityInfo, availability_info: AvailabilityInfo,
) -> Vc<OutputAssets> ) -> Vc<OutputAssetsWithReferenced>
where where
Self: Send; Self: Send;
...@@ -333,6 +336,7 @@ pub trait ChunkingContextExt { ...@@ -333,6 +336,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>,
availability_info: AvailabilityInfo, availability_info: AvailabilityInfo,
) -> Vc<Box<dyn OutputAsset>> ) -> Vc<Box<dyn OutputAsset>>
where where
...@@ -344,6 +348,7 @@ pub trait ChunkingContextExt { ...@@ -344,6 +348,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>,
) -> Vc<EntryChunkGroupResult> ) -> Vc<EntryChunkGroupResult>
where where
Self: Send; Self: Send;
...@@ -354,6 +359,7 @@ pub trait ChunkingContextExt { ...@@ -354,6 +359,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>,
) -> Vc<Box<dyn OutputAsset>> ) -> Vc<Box<dyn OutputAsset>>
where where
Self: Send; Self: Send;
...@@ -364,7 +370,7 @@ pub trait ChunkingContextExt { ...@@ -364,7 +370,7 @@ pub trait ChunkingContextExt {
chunk_group: ChunkGroup, chunk_group: ChunkGroup,
module_graph: Vc<ModuleGraph>, module_graph: Vc<ModuleGraph>,
availability_info: AvailabilityInfo, availability_info: AvailabilityInfo,
) -> Vc<OutputAssets> ) -> Vc<OutputAssetsWithReferenced>
where where
Self: Send; Self: Send;
} }
...@@ -384,7 +390,7 @@ impl<T: ChunkingContext + Send + Upcast<Box<dyn ChunkingContext>>> ChunkingConte ...@@ -384,7 +390,7 @@ impl<T: ChunkingContext + Send + Upcast<Box<dyn ChunkingContext>>> ChunkingConte
ident: Vc<AssetIdent>, ident: Vc<AssetIdent>,
chunk_group: ChunkGroup, chunk_group: ChunkGroup,
module_graph: Vc<ModuleGraph>, module_graph: Vc<ModuleGraph>,
) -> Vc<OutputAssets> { ) -> Vc<OutputAssetsWithReferenced> {
root_chunk_group_assets( root_chunk_group_assets(
Vc::upcast_non_strict(self), Vc::upcast_non_strict(self),
ident, ident,
...@@ -399,7 +405,7 @@ impl<T: ChunkingContext + Send + Upcast<Box<dyn ChunkingContext>>> ChunkingConte ...@@ -399,7 +405,7 @@ impl<T: ChunkingContext + Send + Upcast<Box<dyn ChunkingContext>>> ChunkingConte
chunk_group: ChunkGroup, chunk_group: ChunkGroup,
module_graph: Vc<ModuleGraph>, module_graph: Vc<ModuleGraph>,
availability_info: AvailabilityInfo, availability_info: AvailabilityInfo,
) -> Vc<OutputAssets> { ) -> Vc<OutputAssetsWithReferenced> {
evaluated_chunk_group_assets( evaluated_chunk_group_assets(
Vc::upcast_non_strict(self), Vc::upcast_non_strict(self),
ident, ident,
...@@ -415,6 +421,7 @@ impl<T: ChunkingContext + Send + Upcast<Box<dyn ChunkingContext>>> ChunkingConte ...@@ -415,6 +421,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>,
availability_info: AvailabilityInfo, availability_info: AvailabilityInfo,
) -> Vc<Box<dyn OutputAsset>> { ) -> Vc<Box<dyn OutputAsset>> {
entry_chunk_group_asset( entry_chunk_group_asset(
...@@ -423,6 +430,7 @@ impl<T: ChunkingContext + Send + Upcast<Box<dyn ChunkingContext>>> ChunkingConte ...@@ -423,6 +430,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,
availability_info, availability_info,
) )
} }
...@@ -433,12 +441,14 @@ impl<T: ChunkingContext + Send + Upcast<Box<dyn ChunkingContext>>> ChunkingConte ...@@ -433,12 +441,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>,
) -> 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,
AvailabilityInfo::Root, AvailabilityInfo::Root,
) )
} }
...@@ -449,6 +459,7 @@ impl<T: ChunkingContext + Send + Upcast<Box<dyn ChunkingContext>>> ChunkingConte ...@@ -449,6 +459,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>,
) -> 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),
...@@ -456,6 +467,7 @@ impl<T: ChunkingContext + Send + Upcast<Box<dyn ChunkingContext>>> ChunkingConte ...@@ -456,6 +467,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,
AvailabilityInfo::Root, AvailabilityInfo::Root,
) )
} }
...@@ -466,7 +478,7 @@ impl<T: ChunkingContext + Send + Upcast<Box<dyn ChunkingContext>>> ChunkingConte ...@@ -466,7 +478,7 @@ impl<T: ChunkingContext + Send + Upcast<Box<dyn ChunkingContext>>> ChunkingConte
chunk_group: ChunkGroup, chunk_group: ChunkGroup,
module_graph: Vc<ModuleGraph>, module_graph: Vc<ModuleGraph>,
availability_info: AvailabilityInfo, availability_info: AvailabilityInfo,
) -> Vc<OutputAssets> { ) -> Vc<OutputAssetsWithReferenced> {
chunk_group_assets( chunk_group_assets(
Vc::upcast_non_strict(self), Vc::upcast_non_strict(self),
ident, ident,
...@@ -483,11 +495,15 @@ async fn root_chunk_group_assets( ...@@ -483,11 +495,15 @@ async fn root_chunk_group_assets(
ident: Vc<AssetIdent>, ident: Vc<AssetIdent>,
chunk_group: ChunkGroup, chunk_group: ChunkGroup,
module_graph: Vc<ModuleGraph>, module_graph: Vc<ModuleGraph>,
) -> Result<Vc<OutputAssets>> { ) -> Result<Vc<OutputAssetsWithReferenced>> {
Ok(*chunking_context let root_chunk_group = chunking_context
.root_chunk_group(ident, chunk_group, module_graph) .root_chunk_group(ident, chunk_group, module_graph)
.await? .await?;
.assets) Ok(OutputAssetsWithReferenced {
assets: root_chunk_group.assets,
referenced_assets: root_chunk_group.referenced_assets,
}
.cell())
} }
#[turbo_tasks::function] #[turbo_tasks::function]
...@@ -497,11 +513,15 @@ async fn evaluated_chunk_group_assets( ...@@ -497,11 +513,15 @@ async fn evaluated_chunk_group_assets(
chunk_group: ChunkGroup, chunk_group: ChunkGroup,
module_graph: Vc<ModuleGraph>, module_graph: Vc<ModuleGraph>,
availability_info: AvailabilityInfo, availability_info: AvailabilityInfo,
) -> Result<Vc<OutputAssets>> { ) -> Result<Vc<OutputAssetsWithReferenced>> {
Ok(*chunking_context let evaluated_chunk_group = chunking_context
.evaluated_chunk_group(ident, chunk_group, module_graph, availability_info) .evaluated_chunk_group(ident, chunk_group, module_graph, availability_info)
.await? .await?;
.assets) Ok(OutputAssetsWithReferenced {
assets: evaluated_chunk_group.assets,
referenced_assets: evaluated_chunk_group.referenced_assets,
}
.cell())
} }
#[turbo_tasks::function] #[turbo_tasks::function]
...@@ -511,6 +531,7 @@ async fn entry_chunk_group_asset( ...@@ -511,6 +531,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>,
availability_info: AvailabilityInfo, availability_info: AvailabilityInfo,
) -> Result<Vc<Box<dyn OutputAsset>>> { ) -> Result<Vc<Box<dyn OutputAsset>>> {
Ok(*chunking_context Ok(*chunking_context
...@@ -519,6 +540,7 @@ async fn entry_chunk_group_asset( ...@@ -519,6 +540,7 @@ async fn entry_chunk_group_asset(
evaluatable_assets, evaluatable_assets,
module_graph, module_graph,
extra_chunks, extra_chunks,
extra_referenced_assets,
availability_info, availability_info,
) )
.await? .await?
...@@ -532,9 +554,13 @@ async fn chunk_group_assets( ...@@ -532,9 +554,13 @@ async fn chunk_group_assets(
chunk_group: ChunkGroup, chunk_group: ChunkGroup,
module_graph: Vc<ModuleGraph>, module_graph: Vc<ModuleGraph>,
availability_info: AvailabilityInfo, availability_info: AvailabilityInfo,
) -> Result<Vc<OutputAssets>> { ) -> Result<Vc<OutputAssetsWithReferenced>> {
Ok(*chunking_context let chunk_group = chunking_context
.chunk_group(ident, chunk_group, module_graph, availability_info) .chunk_group(ident, chunk_group, module_graph, availability_info)
.await? .await?;
.assets) Ok(OutputAssetsWithReferenced {
assets: chunk_group.assets,
referenced_assets: chunk_group.referenced_assets,
}
.cell())
} }
...@@ -481,7 +481,6 @@ pub trait ChunkType: ValueToString { ...@@ -481,7 +481,6 @@ pub trait ChunkType: ValueToString {
chunking_context: Vc<Box<dyn ChunkingContext>>, chunking_context: Vc<Box<dyn ChunkingContext>>,
chunk_items: Vec<ChunkItemOrBatchWithAsyncModuleInfo>, chunk_items: Vec<ChunkItemOrBatchWithAsyncModuleInfo>,
batch_groups: Vec<ResolvedVc<ChunkItemBatchGroup>>, batch_groups: Vec<ResolvedVc<ChunkItemBatchGroup>>,
referenced_output_assets: Vc<OutputAssets>,
) -> Vc<Box<dyn Chunk>>; ) -> Vc<Box<dyn Chunk>>;
#[turbo_tasks::function] #[turbo_tasks::function]
......
...@@ -59,3 +59,18 @@ impl OutputAssets { ...@@ -59,3 +59,18 @@ impl OutputAssets {
/// A set of [OutputAsset]s /// A set of [OutputAsset]s
#[turbo_tasks::value(transparent)] #[turbo_tasks::value(transparent)]
pub struct OutputAssetsSet(FxIndexSet<ResolvedVc<Box<dyn OutputAsset>>>); pub struct OutputAssetsSet(FxIndexSet<ResolvedVc<Box<dyn OutputAsset>>>);
#[turbo_tasks::value(shared)]
#[derive(Clone, Copy)]
pub struct OutputAssetsWithReferenced {
pub assets: ResolvedVc<OutputAssets>,
pub referenced_assets: ResolvedVc<OutputAssets>,
}
#[turbo_tasks::value_impl]
impl OutputAssetsWithReferenced {
#[turbo_tasks::function]
pub fn all_assets(&self) -> Vc<OutputAssets> {
self.assets.concatenate(*self.referenced_assets)
}
}
...@@ -236,7 +236,6 @@ pub async fn write_import_context( ...@@ -236,7 +236,6 @@ pub async fn write_import_context(
#[turbo_tasks::value] #[turbo_tasks::value]
pub struct CssChunkContent { pub struct CssChunkContent {
pub chunk_items: Vec<ResolvedVc<Box<dyn CssChunkItem>>>, pub chunk_items: Vec<ResolvedVc<Box<dyn CssChunkItem>>>,
pub referenced_output_assets: ResolvedVc<OutputAssets>,
} }
#[turbo_tasks::value_impl] #[turbo_tasks::value_impl]
...@@ -337,33 +336,30 @@ impl OutputAsset for CssChunk { ...@@ -337,33 +336,30 @@ impl OutputAsset for CssChunk {
async fn references(self: Vc<Self>) -> Result<Vc<OutputAssets>> { async fn references(self: Vc<Self>) -> Result<Vc<OutputAssets>> {
let this = self.await?; let this = self.await?;
let content = this.content.await?; let content = this.content.await?;
let mut references = content.referenced_output_assets.owned().await?;
let should_generate_single_item_chunks = content.chunk_items.len() > 1 let should_generate_single_item_chunks = content.chunk_items.len() > 1
&& *this && *this
.chunking_context .chunking_context
.is_dynamic_chunk_content_loading_enabled() .is_dynamic_chunk_content_loading_enabled()
.await?; .await?;
references.extend( let mut references = content
content .chunk_items
.chunk_items .iter()
.iter() .map(|item| async {
.map(|item| async { let references = item.references().await?.into_iter().copied();
let references = item.references().await?.into_iter().copied(); Ok(if should_generate_single_item_chunks {
Ok(if should_generate_single_item_chunks { Either::Left(
Either::Left( references.chain(std::iter::once(ResolvedVc::upcast(
references.chain(std::iter::once(ResolvedVc::upcast( SingleItemCssChunk::new(*this.chunking_context, **item)
SingleItemCssChunk::new(*this.chunking_context, **item) .to_resolved()
.to_resolved() .await?,
.await?, ))),
))), )
) } else {
} else { Either::Right(references)
Either::Right(references)
})
}) })
.try_flat_join() })
.await?, .try_flat_join()
); .await?;
if *this if *this
.chunking_context .chunking_context
.reference_chunk_source_maps(Vc::upcast(self)) .reference_chunk_source_maps(Vc::upcast(self))
...@@ -501,7 +497,6 @@ impl ChunkType for CssChunkType { ...@@ -501,7 +497,6 @@ impl ChunkType for CssChunkType {
chunking_context: ResolvedVc<Box<dyn ChunkingContext>>, chunking_context: ResolvedVc<Box<dyn ChunkingContext>>,
chunk_items_or_batches: Vec<ChunkItemOrBatchWithAsyncModuleInfo>, chunk_items_or_batches: Vec<ChunkItemOrBatchWithAsyncModuleInfo>,
_batch_groups: Vec<ResolvedVc<ChunkItemBatchGroup>>, _batch_groups: Vec<ResolvedVc<ChunkItemBatchGroup>>,
referenced_output_assets: ResolvedVc<OutputAssets>,
) -> Result<Vc<Box<dyn Chunk>>> { ) -> Result<Vc<Box<dyn Chunk>>> {
let mut chunk_items = Vec::new(); let mut chunk_items = Vec::new();
// TODO operate with batches // TODO operate with batches
...@@ -530,7 +525,6 @@ impl ChunkType for CssChunkType { ...@@ -530,7 +525,6 @@ impl ChunkType for CssChunkType {
}) })
.try_join() .try_join()
.await?, .await?,
referenced_output_assets,
} }
.cell(); .cell();
Ok(Vc::upcast(CssChunk::new(*chunking_context, content))) Ok(Vc::upcast(CssChunk::new(*chunking_context, content)))
......
...@@ -15,7 +15,7 @@ use turbopack_core::{ ...@@ -15,7 +15,7 @@ use turbopack_core::{
}, },
module::Module, module::Module,
module_graph::{ModuleGraph, chunk_group_info::ChunkGroup}, module_graph::{ModuleGraph, chunk_group_info::ChunkGroup},
output::{OutputAsset, OutputAssets}, output::{OutputAsset, OutputAssets, OutputAssetsWithReferenced},
version::{Version, VersionedContent}, version::{Version, VersionedContent},
}; };
...@@ -49,7 +49,7 @@ impl OutputAsset for DevHtmlAsset { ...@@ -49,7 +49,7 @@ impl OutputAsset for DevHtmlAsset {
#[turbo_tasks::function] #[turbo_tasks::function]
fn references(self: Vc<Self>) -> Vc<OutputAssets> { fn references(self: Vc<Self>) -> Vc<OutputAssets> {
self.chunks() self.chunk_group().all_assets()
} }
} }
...@@ -116,7 +116,7 @@ impl DevHtmlAsset { ...@@ -116,7 +116,7 @@ impl DevHtmlAsset {
let this = self.await?; let this = self.await?;
let context_path = this.path.parent(); let context_path = this.path.parent();
let mut chunk_paths = vec![]; let mut chunk_paths = vec![];
for chunk in &*self.chunks().await? { for chunk in &*self.chunk_group().await?.assets.await? {
let chunk_path = &*chunk.path().await?; let chunk_path = &*chunk.path().await?;
if let Some(relative_path) = context_path.get_path_to(chunk_path) { if let Some(relative_path) = context_path.get_path_to(chunk_path) {
chunk_paths.push(format!("/{relative_path}").into()); chunk_paths.push(format!("/{relative_path}").into());
...@@ -127,8 +127,8 @@ impl DevHtmlAsset { ...@@ -127,8 +127,8 @@ impl DevHtmlAsset {
} }
#[turbo_tasks::function] #[turbo_tasks::function]
async fn chunks(&self) -> Result<Vc<OutputAssets>> { async fn chunk_group(&self) -> Result<Vc<OutputAssetsWithReferenced>> {
let all_assets = self let all_chunk_groups = self
.entries .entries
.iter() .iter()
.map(|entry| async move { .map(|entry| async move {
...@@ -139,7 +139,7 @@ impl DevHtmlAsset { ...@@ -139,7 +139,7 @@ impl DevHtmlAsset {
runtime_entries, runtime_entries,
} = entry; } = entry;
let assets = if let Some(runtime_entries) = runtime_entries { let asset_with_referenced = if let Some(runtime_entries) = runtime_entries {
let runtime_entries = let runtime_entries =
if let Some(evaluatable) = ResolvedVc::try_downcast(chunkable_module) { if let Some(evaluatable) = ResolvedVc::try_downcast(chunkable_module) {
runtime_entries runtime_entries
...@@ -149,36 +149,50 @@ impl DevHtmlAsset { ...@@ -149,36 +149,50 @@ impl DevHtmlAsset {
} else { } else {
runtime_entries runtime_entries
}; };
chunking_context.evaluated_chunk_group_assets( chunking_context
chunkable_module.ident(), .evaluated_chunk_group_assets(
ChunkGroup::Entry( chunkable_module.ident(),
runtime_entries ChunkGroup::Entry(
.await? runtime_entries
.iter() .await?
.map(|v| ResolvedVc::upcast(*v)) .iter()
.collect(), .map(|v| ResolvedVc::upcast(*v))
), .collect(),
*module_graph, ),
AvailabilityInfo::Root, *module_graph,
) AvailabilityInfo::Root,
)
.await?
} else { } else {
chunking_context.root_chunk_group_assets( chunking_context
chunkable_module.ident(), .root_chunk_group_assets(
ChunkGroup::Entry(vec![ResolvedVc::upcast(chunkable_module)]), chunkable_module.ident(),
*module_graph, ChunkGroup::Entry(vec![ResolvedVc::upcast(chunkable_module)]),
) *module_graph,
)
.await?
}; };
assets.await Ok((
asset_with_referenced.assets.await?,
asset_with_referenced.referenced_assets.await?,
))
}) })
.try_join() .try_join()
.await? .await?;
.iter()
.flatten()
.copied()
.collect();
Ok(Vc::cell(all_assets)) let mut all_assets = Vec::new();
let mut all_referenced_assets = Vec::new();
for (asset, referenced_asset) in all_chunk_groups {
all_assets.extend(asset);
all_referenced_assets.extend(referenced_asset);
}
Ok(OutputAssetsWithReferenced {
assets: ResolvedVc::cell(all_assets),
referenced_assets: ResolvedVc::cell(all_referenced_assets),
}
.cell())
} }
} }
......
...@@ -11,7 +11,7 @@ use turbopack_core::{ ...@@ -11,7 +11,7 @@ use turbopack_core::{
module_graph::{ module_graph::{
ModuleGraph, chunk_group_info::ChunkGroup, module_batch::ChunkableModuleOrBatch, ModuleGraph, chunk_group_info::ChunkGroup, module_batch::ChunkableModuleOrBatch,
}, },
output::OutputAssets, output::{OutputAssets, OutputAssetsWithReferenced},
}; };
use crate::{ use crate::{
...@@ -34,7 +34,7 @@ pub struct AsyncLoaderChunkItem { ...@@ -34,7 +34,7 @@ pub struct AsyncLoaderChunkItem {
#[turbo_tasks::value_impl] #[turbo_tasks::value_impl]
impl AsyncLoaderChunkItem { impl AsyncLoaderChunkItem {
#[turbo_tasks::function] #[turbo_tasks::function]
pub(super) async fn chunks(&self) -> Result<Vc<OutputAssets>> { pub(super) async fn chunk_group(&self) -> Result<Vc<OutputAssetsWithReferenced>> {
let module = self.module.await?; let module = self.module.await?;
if let Some(chunk_items) = module.availability_info.available_modules() { if let Some(chunk_items) = module.availability_info.available_modules() {
let inner_module = ResolvedVc::upcast(module.inner); let inner_module = ResolvedVc::upcast(module.inner);
...@@ -47,7 +47,11 @@ impl AsyncLoaderChunkItem { ...@@ -47,7 +47,11 @@ impl AsyncLoaderChunkItem {
ChunkableModuleOrBatch::from_module_or_batch(module_or_batch) ChunkableModuleOrBatch::from_module_or_batch(module_or_batch)
&& *chunk_items.get(chunkable_module_or_batch).await? && *chunk_items.get(chunkable_module_or_batch).await?
{ {
return Ok(Vc::cell(vec![])); return Ok(OutputAssetsWithReferenced {
assets: ResolvedVc::cell(vec![]),
referenced_assets: ResolvedVc::cell(vec![]),
}
.cell());
} }
} }
Ok(self.chunking_context.chunk_group_assets( Ok(self.chunking_context.chunk_group_assets(
...@@ -63,7 +67,7 @@ impl AsyncLoaderChunkItem { ...@@ -63,7 +67,7 @@ impl AsyncLoaderChunkItem {
let this = self.await?; let this = self.await?;
Ok(ChunkData::from_assets( Ok(ChunkData::from_assets(
this.chunking_context.output_root().owned().await?, this.chunking_context.output_root().owned().await?,
self.chunks(), *self.chunk_group().await?.assets,
)) ))
} }
} }
...@@ -162,7 +166,7 @@ impl ChunkItem for AsyncLoaderChunkItem { ...@@ -162,7 +166,7 @@ impl ChunkItem for AsyncLoaderChunkItem {
#[turbo_tasks::function] #[turbo_tasks::function]
fn references(self: Vc<Self>) -> Vc<OutputAssets> { fn references(self: Vc<Self>) -> Vc<OutputAssets> {
self.chunks() self.chunk_group().all_assets()
} }
#[turbo_tasks::function] #[turbo_tasks::function]
......
use anyhow::{Result, bail}; use anyhow::{Result, bail};
use turbo_rcstr::{RcStr, rcstr}; use turbo_rcstr::{RcStr, rcstr};
use turbo_tasks::{ResolvedVc, TryJoinIterExt, ValueDefault, ValueToString, Vc}; use turbo_tasks::{ResolvedVc, TryJoinIterExt, ValueDefault, ValueToString, Vc};
use turbopack_core::{ use turbopack_core::chunk::{
chunk::{ AsyncModuleInfo, Chunk, ChunkItem, ChunkItemBatchGroup, ChunkItemOrBatchWithAsyncModuleInfo,
AsyncModuleInfo, Chunk, ChunkItem, ChunkItemBatchGroup, ChunkType, ChunkingContext, round_chunk_item_size,
ChunkItemOrBatchWithAsyncModuleInfo, ChunkType, ChunkingContext, round_chunk_item_size,
},
output::OutputAssets,
}; };
use super::{EcmascriptChunk, EcmascriptChunkContent, EcmascriptChunkItem}; use super::{EcmascriptChunk, EcmascriptChunkContent, EcmascriptChunkItem};
...@@ -37,7 +34,6 @@ impl ChunkType for EcmascriptChunkType { ...@@ -37,7 +34,6 @@ impl ChunkType for EcmascriptChunkType {
chunking_context: Vc<Box<dyn ChunkingContext>>, chunking_context: Vc<Box<dyn ChunkingContext>>,
chunk_items: Vec<ChunkItemOrBatchWithAsyncModuleInfo>, chunk_items: Vec<ChunkItemOrBatchWithAsyncModuleInfo>,
batch_groups: Vec<ResolvedVc<ChunkItemBatchGroup>>, batch_groups: Vec<ResolvedVc<ChunkItemBatchGroup>>,
referenced_output_assets: Vc<OutputAssets>,
) -> Result<Vc<Box<dyn Chunk>>> { ) -> Result<Vc<Box<dyn Chunk>>> {
let content = EcmascriptChunkContent { let content = EcmascriptChunkContent {
chunk_items: chunk_items chunk_items: chunk_items
...@@ -53,7 +49,6 @@ impl ChunkType for EcmascriptChunkType { ...@@ -53,7 +49,6 @@ impl ChunkType for EcmascriptChunkType {
}) })
.try_join() .try_join()
.await?, .await?,
referenced_output_assets: referenced_output_assets.owned().await?,
} }
.cell(); .cell();
Ok(Vc::upcast(EcmascriptChunk::new(chunking_context, content))) Ok(Vc::upcast(EcmascriptChunk::new(chunking_context, content)))
......
...@@ -3,10 +3,7 @@ use std::future::IntoFuture; ...@@ -3,10 +3,7 @@ use std::future::IntoFuture;
use anyhow::Result; use anyhow::Result;
use either::Either; use either::Either;
use turbo_tasks::{ReadRef, ResolvedVc, TryJoinIterExt, Vc}; use turbo_tasks::{ReadRef, ResolvedVc, TryJoinIterExt, Vc};
use turbopack_core::{ use turbopack_core::chunk::{ChunkItem, ChunkItems, batch_info};
chunk::{ChunkItem, ChunkItems, batch_info},
output::OutputAsset,
};
use crate::chunk::{ use crate::chunk::{
CodeAndIds, CodeAndIds,
...@@ -18,7 +15,6 @@ use crate::chunk::{ ...@@ -18,7 +15,6 @@ use crate::chunk::{
pub struct EcmascriptChunkContent { pub struct EcmascriptChunkContent {
pub chunk_items: Vec<EcmascriptChunkItemOrBatchWithAsyncInfo>, pub chunk_items: Vec<EcmascriptChunkItemOrBatchWithAsyncInfo>,
pub batch_groups: Vec<ResolvedVc<EcmascriptChunkItemBatchGroup>>, pub batch_groups: Vec<ResolvedVc<EcmascriptChunkItemBatchGroup>>,
pub referenced_output_assets: Vec<ResolvedVc<Box<dyn OutputAsset>>>,
} }
#[turbo_tasks::value_impl] #[turbo_tasks::value_impl]
......
...@@ -19,7 +19,7 @@ use turbopack_core::{ ...@@ -19,7 +19,7 @@ use turbopack_core::{
Introspectable, IntrospectableChildren, module::IntrospectableModule, Introspectable, IntrospectableChildren, module::IntrospectableModule,
utils::children_from_output_assets, utils::children_from_output_assets,
}, },
output::{OutputAsset, OutputAssets}, output::OutputAssets,
server_fs::ServerFileSystem, server_fs::ServerFileSystem,
}; };
...@@ -130,13 +130,12 @@ impl Chunk for EcmascriptChunk { ...@@ -130,13 +130,12 @@ impl Chunk for EcmascriptChunk {
#[turbo_tasks::function] #[turbo_tasks::function]
async fn references(&self) -> Result<Vc<OutputAssets>> { async fn references(&self) -> Result<Vc<OutputAssets>> {
let content = self.content.await?; let content = self.content.await?;
let mut referenced_output_assets: Vec<ResolvedVc<Box<dyn OutputAsset>>> = content let referenced_output_assets = content
.chunk_items .chunk_items
.iter() .iter()
.map(async |with_info| Ok(with_info.references().await?.into_iter().copied())) .map(async |with_info| Ok(with_info.references().await?.into_iter().copied()))
.try_flat_join() .try_flat_join()
.await?; .await?;
referenced_output_assets.extend(content.referenced_output_assets.iter().copied());
Ok(Vc::cell(referenced_output_assets)) Ok(Vc::cell(referenced_output_assets))
} }
......
...@@ -11,7 +11,7 @@ use turbopack_core::{ ...@@ -11,7 +11,7 @@ use turbopack_core::{
module_graph::{ module_graph::{
ModuleGraph, chunk_group_info::ChunkGroup, module_batch::ChunkableModuleOrBatch, ModuleGraph, chunk_group_info::ChunkGroup, module_batch::ChunkableModuleOrBatch,
}, },
output::OutputAssets, output::OutputAssetsWithReferenced,
reference::{ModuleReferences, SingleOutputAssetReference}, reference::{ModuleReferences, SingleOutputAssetReference},
}; };
...@@ -55,7 +55,7 @@ impl ManifestAsyncModule { ...@@ -55,7 +55,7 @@ impl ManifestAsyncModule {
} }
#[turbo_tasks::function] #[turbo_tasks::function]
pub(super) fn chunks(&self) -> Vc<OutputAssets> { pub(super) fn chunk_group(&self) -> Vc<OutputAssetsWithReferenced> {
self.chunking_context.chunk_group_assets( self.chunking_context.chunk_group_assets(
self.inner.ident(), self.inner.ident(),
ChunkGroup::Async(ResolvedVc::upcast(self.inner)), ChunkGroup::Async(ResolvedVc::upcast(self.inner)),
...@@ -65,7 +65,9 @@ impl ManifestAsyncModule { ...@@ -65,7 +65,9 @@ impl ManifestAsyncModule {
} }
#[turbo_tasks::function] #[turbo_tasks::function]
pub async fn manifest_chunks(self: ResolvedVc<Self>) -> Result<Vc<OutputAssets>> { pub async fn manifest_chunk_group(
self: ResolvedVc<Self>,
) -> Result<Vc<OutputAssetsWithReferenced>> {
let this = self.await?; let this = self.await?;
if let Some(chunk_items) = this.availability_info.available_modules() { if let Some(chunk_items) = this.availability_info.available_modules() {
let inner_module = ResolvedVc::upcast(this.inner); let inner_module = ResolvedVc::upcast(this.inner);
...@@ -78,7 +80,11 @@ impl ManifestAsyncModule { ...@@ -78,7 +80,11 @@ impl ManifestAsyncModule {
ChunkableModuleOrBatch::from_module_or_batch(module_or_batch) ChunkableModuleOrBatch::from_module_or_batch(module_or_batch)
&& *chunk_items.get(chunkable_module_or_batch).await? && *chunk_items.get(chunkable_module_or_batch).await?
{ {
return Ok(Vc::cell(vec![])); return Ok(OutputAssetsWithReferenced {
assets: ResolvedVc::cell(vec![]),
referenced_assets: ResolvedVc::cell(vec![]),
}
.cell());
} }
} }
Ok(this.chunking_context.chunk_group_assets( Ok(this.chunking_context.chunk_group_assets(
...@@ -119,12 +125,11 @@ impl Module for ManifestAsyncModule { ...@@ -119,12 +125,11 @@ impl Module for ManifestAsyncModule {
#[turbo_tasks::function] #[turbo_tasks::function]
async fn references(self: Vc<Self>) -> Result<Vc<ModuleReferences>> { async fn references(self: Vc<Self>) -> Result<Vc<ModuleReferences>> {
let chunks = self.chunks(); let assets = self.chunk_group().all_assets().await?;
Ok(Vc::cell( Ok(Vc::cell(
chunks assets
.await? .into_iter()
.iter()
.copied() .copied()
.map(|chunk| async move { .map(|chunk| async move {
Ok(ResolvedVc::upcast( Ok(ResolvedVc::upcast(
......
...@@ -33,7 +33,7 @@ impl ManifestChunkItem { ...@@ -33,7 +33,7 @@ impl ManifestChunkItem {
async fn chunks_data(&self) -> Result<Vc<ChunksData>> { async fn chunks_data(&self) -> Result<Vc<ChunksData>> {
Ok(ChunkData::from_assets( Ok(ChunkData::from_assets(
self.chunking_context.output_root().owned().await?, self.chunking_context.output_root().owned().await?,
self.manifest.chunks(), *self.manifest.chunk_group().await?.assets,
)) ))
} }
} }
...@@ -77,8 +77,8 @@ impl ChunkItem for ManifestChunkItem { ...@@ -77,8 +77,8 @@ impl ChunkItem for ManifestChunkItem {
} }
#[turbo_tasks::function] #[turbo_tasks::function]
async fn references(&self) -> Result<Vc<OutputAssets>> { fn references(&self) -> Vc<OutputAssets> {
Ok(self.manifest.chunks()) self.manifest.chunk_group().all_assets()
} }
#[turbo_tasks::function] #[turbo_tasks::function]
......
...@@ -67,10 +67,10 @@ impl ManifestLoaderChunkItem { ...@@ -67,10 +67,10 @@ impl ManifestLoaderChunkItem {
#[turbo_tasks::function] #[turbo_tasks::function]
pub async fn chunks_data(&self) -> Result<Vc<ChunksData>> { pub async fn chunks_data(&self) -> Result<Vc<ChunksData>> {
let chunks = self.manifest.manifest_chunks(); let chunks = self.manifest.manifest_chunk_group().await?.assets;
Ok(ChunkData::from_assets( Ok(ChunkData::from_assets(
self.chunking_context.output_root().owned().await?, self.chunking_context.output_root().owned().await?,
chunks, *chunks,
)) ))
} }
...@@ -93,8 +93,8 @@ impl ChunkItem for ManifestLoaderChunkItem { ...@@ -93,8 +93,8 @@ impl ChunkItem for ManifestLoaderChunkItem {
} }
#[turbo_tasks::function] #[turbo_tasks::function]
async fn references(&self) -> Result<Vc<OutputAssets>> { fn references(&self) -> Vc<OutputAssets> {
Ok(self.manifest.manifest_chunks()) self.manifest.manifest_chunk_group().all_assets()
} }
#[turbo_tasks::function] #[turbo_tasks::function]
......
...@@ -10,7 +10,7 @@ use turbopack_core::{ ...@@ -10,7 +10,7 @@ use turbopack_core::{
ident::AssetIdent, ident::AssetIdent,
module::Module, module::Module,
module_graph::{ModuleGraph, chunk_group_info::ChunkGroup}, module_graph::{ModuleGraph, chunk_group_info::ChunkGroup},
output::OutputAssets, output::{OutputAssets, OutputAssetsWithReferenced},
}; };
use super::module::WorkerLoaderModule; use super::module::WorkerLoaderModule;
...@@ -33,7 +33,7 @@ pub struct WorkerLoaderChunkItem { ...@@ -33,7 +33,7 @@ pub struct WorkerLoaderChunkItem {
#[turbo_tasks::value_impl] #[turbo_tasks::value_impl]
impl WorkerLoaderChunkItem { impl WorkerLoaderChunkItem {
#[turbo_tasks::function] #[turbo_tasks::function]
async fn chunks(&self) -> Result<Vc<OutputAssets>> { async fn chunk_group(&self) -> Result<Vc<OutputAssetsWithReferenced>> {
let module = self.module.await?; let module = self.module.await?;
Ok(self.chunking_context.evaluated_chunk_group_assets( Ok(self.chunking_context.evaluated_chunk_group_assets(
...@@ -49,7 +49,7 @@ impl WorkerLoaderChunkItem { ...@@ -49,7 +49,7 @@ impl WorkerLoaderChunkItem {
let this = self.await?; let this = self.await?;
Ok(ChunkData::from_assets( Ok(ChunkData::from_assets(
this.chunking_context.output_root().owned().await?, this.chunking_context.output_root().owned().await?,
self.chunks(), *self.chunk_group().await?.assets,
)) ))
} }
} }
...@@ -94,7 +94,7 @@ impl ChunkItem for WorkerLoaderChunkItem { ...@@ -94,7 +94,7 @@ impl ChunkItem for WorkerLoaderChunkItem {
#[turbo_tasks::function] #[turbo_tasks::function]
fn references(self: Vc<Self>) -> Vc<OutputAssets> { fn references(self: Vc<Self>) -> Vc<OutputAssets> {
self.chunks() self.chunk_group().all_assets()
} }
#[turbo_tasks::function] #[turbo_tasks::function]
......
...@@ -177,6 +177,7 @@ async fn emit_evaluate_pool_assets_operation( ...@@ -177,6 +177,7 @@ async fn emit_evaluate_pool_assets_operation(
.with_entry(*ResolvedVc::try_downcast(entry_module).unwrap()), .with_entry(*ResolvedVc::try_downcast(entry_module).unwrap()),
module_graph, module_graph,
OutputAssets::empty(), OutputAssets::empty(),
OutputAssets::empty(),
); );
let output_root = chunking_context.output_root().owned().await?; let output_root = chunking_context.output_root().owned().await?;
......
...@@ -280,6 +280,7 @@ pub async fn get_intermediate_asset( ...@@ -280,6 +280,7 @@ pub async fn get_intermediate_asset(
false, false,
), ),
OutputAssets::empty(), OutputAssets::empty(),
OutputAssets::empty(),
)) ))
} }
......
...@@ -388,6 +388,7 @@ impl ChunkingContext for NodeJsChunkingContext { ...@@ -388,6 +388,7 @@ impl ChunkingContext for NodeJsChunkingContext {
let modules = chunk_group.entries(); let modules = chunk_group.entries();
let MakeChunkGroupResult { let MakeChunkGroupResult {
chunks, chunks,
referenced_output_assets,
availability_info, availability_info,
} = make_chunk_group( } = make_chunk_group(
modules, modules,
...@@ -405,6 +406,7 @@ impl ChunkingContext for NodeJsChunkingContext { ...@@ -405,6 +406,7 @@ impl ChunkingContext for NodeJsChunkingContext {
Ok(ChunkGroupResult { Ok(ChunkGroupResult {
assets: ResolvedVc::cell(assets), assets: ResolvedVc::cell(assets),
referenced_assets: ResolvedVc::cell(referenced_output_assets),
availability_info, availability_info,
} }
.cell()) .cell())
...@@ -420,6 +422,7 @@ impl ChunkingContext for NodeJsChunkingContext { ...@@ -420,6 +422,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>,
availability_info: AvailabilityInfo, availability_info: AvailabilityInfo,
) -> Result<Vc<EntryChunkGroupResult>> { ) -> Result<Vc<EntryChunkGroupResult>> {
let evaluatable_assets_ref = evaluatable_assets.await?; let evaluatable_assets_ref = evaluatable_assets.await?;
...@@ -429,6 +432,7 @@ impl ChunkingContext for NodeJsChunkingContext { ...@@ -429,6 +432,7 @@ impl ChunkingContext for NodeJsChunkingContext {
let MakeChunkGroupResult { let MakeChunkGroupResult {
chunks, chunks,
mut referenced_output_assets,
availability_info, availability_info,
} = make_chunk_group( } = make_chunk_group(
entries, entries,
...@@ -439,17 +443,14 @@ impl ChunkingContext for NodeJsChunkingContext { ...@@ -439,17 +443,14 @@ impl ChunkingContext for NodeJsChunkingContext {
.await?; .await?;
let extra_chunks = extra_chunks.await?; let extra_chunks = extra_chunks.await?;
let other_chunks: Vec<_> = extra_chunks let mut other_chunks = chunks
.iter() .iter()
.copied() .map(|chunk| self.generate_chunk(**chunk).to_resolved())
.chain( .try_join()
chunks .await?;
.iter() other_chunks.extend(extra_chunks.iter().copied());
.map(|chunk| self.generate_chunk(**chunk).to_resolved())
.try_join() referenced_output_assets.extend(extra_referenced_assets.await?.iter().copied());
.await?,
)
.collect();
let Some(module) = ResolvedVc::try_sidecast(*evaluatable_assets_ref.last().unwrap()) else { let Some(module) = ResolvedVc::try_sidecast(*evaluatable_assets_ref.last().unwrap()) else {
bail!("module must be placeable in an ecmascript chunk"); bail!("module must be placeable in an ecmascript chunk");
...@@ -461,6 +462,7 @@ impl ChunkingContext for NodeJsChunkingContext { ...@@ -461,6 +462,7 @@ impl ChunkingContext for NodeJsChunkingContext {
Vc::cell(other_chunks), Vc::cell(other_chunks),
evaluatable_assets, evaluatable_assets,
*module, *module,
Vc::cell(referenced_output_assets),
module_graph, module_graph,
*self, *self,
) )
......
...@@ -26,6 +26,7 @@ pub(crate) struct EcmascriptBuildNodeEntryChunk { ...@@ -26,6 +26,7 @@ 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>,
module_graph: ResolvedVc<ModuleGraph>, module_graph: ResolvedVc<ModuleGraph>,
chunking_context: ResolvedVc<NodeJsChunkingContext>, chunking_context: ResolvedVc<NodeJsChunkingContext>,
} }
...@@ -39,6 +40,7 @@ impl EcmascriptBuildNodeEntryChunk { ...@@ -39,6 +40,7 @@ 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>,
module_graph: ResolvedVc<ModuleGraph>, module_graph: ResolvedVc<ModuleGraph>,
chunking_context: ResolvedVc<NodeJsChunkingContext>, chunking_context: ResolvedVc<NodeJsChunkingContext>,
) -> Vc<Self> { ) -> Vc<Self> {
...@@ -47,6 +49,7 @@ impl EcmascriptBuildNodeEntryChunk { ...@@ -47,6 +49,7 @@ impl EcmascriptBuildNodeEntryChunk {
other_chunks, other_chunks,
evaluatable_assets, evaluatable_assets,
exported_module, exported_module,
referenced_output_assets,
module_graph, module_graph,
chunking_context, chunking_context,
} }
...@@ -191,6 +194,11 @@ impl OutputAsset for EcmascriptBuildNodeEntryChunk { ...@@ -191,6 +194,11 @@ impl OutputAsset for EcmascriptBuildNodeEntryChunk {
let other_chunks = this.other_chunks.await?; let other_chunks = this.other_chunks.await?;
references.extend(other_chunks.iter().copied()); references.extend(other_chunks.iter().copied());
let referenced_output_assets = this.referenced_output_assets.await?;
for &referenced_output_asset in &*referenced_output_assets {
references.push(referenced_output_asset);
}
Ok(Vc::cell(references)) Ok(Vc::cell(references))
} }
} }
......
...@@ -50,7 +50,7 @@ use turbopack_core::{ ...@@ -50,7 +50,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}, output::{OutputAsset, OutputAssets, OutputAssetsWithReferenced},
reference_type::{EntryReferenceSubType, ReferenceType}, reference_type::{EntryReferenceSubType, ReferenceType},
source::Source, source::Source,
}; };
...@@ -511,28 +511,33 @@ async fn run_test_operation(resource: RcStr) -> Result<Vc<FileSystemPath>> { ...@@ -511,28 +511,33 @@ async fn run_test_operation(resource: RcStr) -> Result<Vc<FileSystemPath>> {
AvailabilityInfo::Root, AvailabilityInfo::Root,
), ),
Runtime::NodeJs => { Runtime::NodeJs => {
Vc::cell(vec![ OutputAssetsWithReferenced {
Vc::try_resolve_downcast_type::<NodeJsChunkingContext>(chunking_context) assets: ResolvedVc::cell(vec![
.await? Vc::try_resolve_downcast_type::<NodeJsChunkingContext>(chunking_context)
.unwrap() .await?
.entry_chunk_group( .unwrap()
// `expected` expects a completely flat output directory. .entry_chunk_group(
chunk_root_path // `expected` expects a completely flat output directory.
.join(entry_module.ident().path().await?.file_stem().unwrap())? chunk_root_path
.with_extension("entry.js"), .join(entry_module.ident().path().await?.file_stem().unwrap())?
evaluatable_assets, .with_extension("entry.js"),
module_graph, evaluatable_assets,
OutputAssets::empty(), module_graph,
AvailabilityInfo::Root, OutputAssets::empty(),
) OutputAssets::empty(),
.await? AvailabilityInfo::Root,
.asset, )
]) .await?
.asset,
]),
referenced_assets: ResolvedVc::cell(vec![]),
}
.cell()
} }
}; };
let mut seen = FxHashSet::default(); let mut seen = FxHashSet::default();
let mut queue: VecDeque<_> = chunks.await?.iter().copied().collect(); let mut queue: VecDeque<_> = chunks.all_assets().await?.iter().copied().collect();
let output_path = project_path.clone(); let output_path = project_path.clone();
while let Some(asset) = queue.pop_front() { while let Some(asset) = queue.pop_front() {
......
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