Skip to content

Commit e0aef09

Browse files
committed
Set correct IsolatedMerged values
1 parent 0562d60 commit e0aef09

File tree

2 files changed

+24
-6
lines changed

2 files changed

+24
-6
lines changed

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

+10-4
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,8 @@ pub async fn get_app_client_references_chunks(
169169
list.extend(framework_reference_types);
170170
}
171171

172+
let chunk_group_info = module_graph.chunk_group_info();
173+
172174
let mut current_client_availability_info = client_availability_info.into_value();
173175
let mut current_client_chunks = OutputAssets::empty().to_resolved().await?;
174176
let mut current_ssr_availability_info = AvailabilityInfo::Root;
@@ -181,6 +183,12 @@ pub async fn get_app_client_references_chunks(
181183
for (server_component, client_reference_types) in
182184
client_references_by_server_component.into_iter()
183185
{
186+
let parent_chunk_group = *chunk_group_info
187+
.get_index_of(ChunkGroup::Shared(ResolvedVc::upcast(
188+
server_component.await?.module,
189+
)))
190+
.await?;
191+
184192
let base_ident = server_component.ident();
185193

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

218226
ssr_chunking_context.chunk_group(
219227
base_ident.with_modifier(ssr_modules_modifier()),
220-
// TODO use correct parameters here, and sort the modules?
221228
ChunkGroup::IsolatedMerged {
222-
parent: 0,
229+
parent: parent_chunk_group,
223230
merge_tag: ECMASCRIPT_CLIENT_REFERENCE_MERGE_TAG_SSR.clone(),
224231
entries: ssr_modules,
225232
},
@@ -256,9 +263,8 @@ pub async fn get_app_client_references_chunks(
256263

257264
Some(client_chunking_context.chunk_group(
258265
base_ident.with_modifier(client_modules_modifier()),
259-
// TODO use correct parameters here, and sort the modules?
260266
ChunkGroup::IsolatedMerged {
261-
parent: 0,
267+
parent: parent_chunk_group,
262268
merge_tag: ECMASCRIPT_CLIENT_REFERENCE_MERGE_TAG_CLIENT.clone(),
263269
entries: client_modules,
264270
},

turbopack/crates/turbopack-core/src/module_graph/chunk_group_info.rs

+14-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use std::{
44
ops::{Deref, DerefMut},
55
};
66

7-
use anyhow::Result;
7+
use anyhow::{bail, Result};
88
use either::Either;
99
use indexmap::map::Entry;
1010
use petgraph::graph::{DiGraph, EdgeIndex, NodeIndex};
@@ -88,7 +88,19 @@ impl Hash for RoaringBitmapWrapper {
8888
pub struct ChunkGroupInfo {
8989
pub module_chunk_groups: FxHashMap<ResolvedVc<Box<dyn Module>>, RoaringBitmapWrapper>,
9090
#[turbo_tasks(trace_ignore)]
91-
pub chunk_groups: Vec<ChunkGroup>,
91+
pub chunk_groups: FxIndexSet<ChunkGroup>,
92+
}
93+
94+
#[turbo_tasks::value_impl]
95+
impl ChunkGroupInfo {
96+
#[turbo_tasks::function]
97+
pub fn get_index_of(&self, chunk_group: ChunkGroup) -> Result<Vc<usize>> {
98+
if let Some(idx) = self.chunk_groups.get_index_of(&chunk_group) {
99+
Ok(Vc::cell(idx))
100+
} else {
101+
bail!("Couldn't find chunk group index");
102+
}
103+
}
92104
}
93105

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

0 commit comments

Comments
 (0)