Skip to content

Commit

Permalink
Set correct IsolatedMerged values
Browse files Browse the repository at this point in the history
  • Loading branch information
mischnic authored and sokra committed Feb 23, 2025
1 parent 44e338b commit 33c056a
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 6 deletions.
14 changes: 10 additions & 4 deletions crates/next-core/src/next_app/app_client_references_chunks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,8 @@ pub async fn get_app_client_references_chunks(
list.extend(framework_reference_types);
}

let chunk_group_info = module_graph.chunk_group_info();

let mut current_client_availability_info = client_availability_info.into_value();
let mut current_client_chunks = OutputAssets::empty().to_resolved().await?;
let mut current_ssr_availability_info = AvailabilityInfo::Root;
Expand All @@ -181,6 +183,12 @@ pub async fn get_app_client_references_chunks(
for (server_component, client_reference_types) in
client_references_by_server_component.into_iter()
{
let parent_chunk_group = *chunk_group_info
.get_index_of(ChunkGroup::Shared(ResolvedVc::upcast(
server_component.await?.module,
)))
.await?;

let base_ident = server_component.ident();

let server_path = server_component.server_path();
Expand Down Expand Up @@ -217,9 +225,8 @@ pub async fn get_app_client_references_chunks(

ssr_chunking_context.chunk_group(
base_ident.with_modifier(ssr_modules_modifier()),
// TODO use correct parameters here, and sort the modules?
ChunkGroup::IsolatedMerged {
parent: 0,
parent: parent_chunk_group,
merge_tag: ECMASCRIPT_CLIENT_REFERENCE_MERGE_TAG_SSR.clone(),
entries: ssr_modules,
},
Expand Down Expand Up @@ -256,9 +263,8 @@ pub async fn get_app_client_references_chunks(

Some(client_chunking_context.chunk_group(
base_ident.with_modifier(client_modules_modifier()),
// TODO use correct parameters here, and sort the modules?
ChunkGroup::IsolatedMerged {
parent: 0,
parent: parent_chunk_group,
merge_tag: ECMASCRIPT_CLIENT_REFERENCE_MERGE_TAG_CLIENT.clone(),
entries: client_modules,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use std::{
ops::{Deref, DerefMut},
};

use anyhow::Result;
use anyhow::{bail, Result};
use either::Either;
use indexmap::map::Entry;
use petgraph::graph::{DiGraph, EdgeIndex, NodeIndex};
Expand Down Expand Up @@ -88,7 +88,19 @@ impl Hash for RoaringBitmapWrapper {
pub struct ChunkGroupInfo {
pub module_chunk_groups: FxHashMap<ResolvedVc<Box<dyn Module>>, RoaringBitmapWrapper>,
#[turbo_tasks(trace_ignore)]
pub chunk_groups: Vec<ChunkGroup>,
pub chunk_groups: FxIndexSet<ChunkGroup>,
}

#[turbo_tasks::value_impl]
impl ChunkGroupInfo {
#[turbo_tasks::function]
pub fn get_index_of(&self, chunk_group: ChunkGroup) -> Result<Vc<usize>> {
if let Some(idx) = self.chunk_groups.get_index_of(&chunk_group) {
Ok(Vc::cell(idx))
} else {
bail!("Couldn't find chunk group index");
}
}
}

#[derive(Debug, Clone, Hash, TaskInput, PartialEq, Eq, Serialize, Deserialize)]
Expand Down

0 comments on commit 33c056a

Please sign in to comment.