Skip to content

Commit 51f2c54

Browse files
fix(mf): skip sync initial consumes under async startup
1 parent 8cb5b35 commit 51f2c54

File tree

1 file changed

+18
-11
lines changed

1 file changed

+18
-11
lines changed

crates/rspack_plugin_mf/src/sharing/consume_shared_runtime_module.rs

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,11 @@ impl RuntimeModule for ConsumeSharedRuntimeModule {
4141
.chunk
4242
.expect("should have chunk in <ConsumeSharedRuntimeModule as RuntimeModule>::generate");
4343
let chunk = compilation.chunk_by_ukey.expect_get(&chunk_ukey);
44+
let chunk_runtime_requirements =
45+
ChunkGraph::get_chunk_runtime_requirements(compilation, &chunk_ukey);
46+
let async_federation_startup = chunk_runtime_requirements
47+
.map(|req| req.contains(RuntimeGlobals::ASYNC_FEDERATION_STARTUP))
48+
.unwrap_or(false);
4449
let module_graph = compilation.get_module_graph();
4550
let mut chunk_to_module_mapping = FxHashMap::default();
4651
let mut module_id_to_consume_data_mapping = FxHashMap::default();
@@ -91,17 +96,19 @@ impl RuntimeModule for ConsumeSharedRuntimeModule {
9196
ids,
9297
);
9398
}
94-
for chunk in chunk.get_all_initial_chunks(&compilation.chunk_group_by_ukey) {
95-
let modules = compilation
96-
.chunk_graph
97-
.get_chunk_modules_identifier_by_source_type(
98-
&chunk,
99-
SourceType::ConsumeShared,
100-
&module_graph,
101-
);
102-
let chunk = compilation.chunk_by_ukey.expect_get(&chunk);
103-
for mid in modules {
104-
add_module(mid, chunk, &mut initial_consumes);
99+
if !async_federation_startup {
100+
for chunk in chunk.get_all_initial_chunks(&compilation.chunk_group_by_ukey) {
101+
let modules = compilation
102+
.chunk_graph
103+
.get_chunk_modules_identifier_by_source_type(
104+
&chunk,
105+
SourceType::ConsumeShared,
106+
&module_graph,
107+
);
108+
let chunk = compilation.chunk_by_ukey.expect_get(&chunk);
109+
for mid in modules {
110+
add_module(mid, chunk, &mut initial_consumes);
111+
}
105112
}
106113
}
107114
let module_id_to_consume_data_mapping = if module_id_to_consume_data_mapping.is_empty() {

0 commit comments

Comments
 (0)