Skip to content

Commit

Permalink
fix: mf manifest remoteEntry address
Browse files Browse the repository at this point in the history
  • Loading branch information
xusd320 committed Feb 7, 2025
1 parent f9e1174 commit b121dbf
Showing 1 changed file with 31 additions and 24 deletions.
55 changes: 31 additions & 24 deletions crates/mako/src/plugins/module_federation/manifest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,27 +114,34 @@ impl ModuleFederationPlugin {
})
.collect()
},
meta_data: ManifestMetaData {
name: self.config.name.clone(),
build_info: ManifestMetaBuildInfo {
build_name: app_info.0.unwrap_or("default".to_string()),
build_version: app_info.1.unwrap_or("".to_string()),
},
global_name: self.config.name.clone(),
public_path: "auto".to_string(),
r#type: "global".to_string(),
remote_entry: self.config.exposes.as_ref().and_then(|exposes| {
if exposes.is_empty() {
None
} else {
Some(ManifestMetaRemoteEntry {
name: format!("{}.js", self.config.name),
path: "".to_string(),
r#type: "global".to_string(),
})
}
}),
..Default::default()
meta_data: {
let chunk_graph = context.chunk_graph.read().unwrap();
let mf_containter_entry_root_module: Option<ModuleId> = context

Check warning on line 119 in crates/mako/src/plugins/module_federation/manifest.rs

View workflow job for this annotation

GitHub Actions / Spell Check

"containter" should be "container".
.config
.entry
.get(&self.config.name)
.map(|e| e.import.to_string_lossy().to_string().into());
let mf_containter_entry_chunk = mf_containter_entry_root_module

Check warning on line 124 in crates/mako/src/plugins/module_federation/manifest.rs

View workflow job for this annotation

GitHub Actions / Spell Check

"containter" should be "container".

Check warning on line 124 in crates/mako/src/plugins/module_federation/manifest.rs

View workflow job for this annotation

GitHub Actions / Spell Check

"containter" should be "container".
.map(|m| chunk_graph.get_chunk_for_module(&m).unwrap());

ManifestMetaData {
name: self.config.name.clone(),
build_info: ManifestMetaBuildInfo {
build_name: app_info.0.unwrap_or("default".to_string()),
build_version: app_info.1.unwrap_or("".to_string()),
},
global_name: self.config.name.clone(),
// FIXME: hardcode now
public_path: "auto".to_string(),
// FIXME: hardcode now
r#type: "global".to_string(),
remote_entry: mf_containter_entry_chunk.map(|c| ManifestMetaRemoteEntry {

Check warning on line 138 in crates/mako/src/plugins/module_federation/manifest.rs

View workflow job for this annotation

GitHub Actions / Spell Check

"containter" should be "container".
name: extract_assets(&[c.id.clone()], &params.stats).0[0].clone(),
path: "".to_string(),
r#type: "global".to_string(),
}),
..Default::default()
}
},
};
fs::write(
Expand Down Expand Up @@ -163,9 +170,9 @@ fn extract_chunk_assets(
acc
});

let (sync_js_files, sync_css_files) = extract_assets(all_sync_chunks, &params.stats);
let (sync_js_files, sync_css_files) = extract_assets(&all_sync_chunks, &params.stats);

let (async_js_files, async_css_files) = extract_assets(all_async_chunks, &params.stats);
let (async_js_files, async_css_files) = extract_assets(&all_async_chunks, &params.stats);

let async_js_files = async_js_files
.into_iter()
Expand All @@ -190,7 +197,7 @@ fn extract_chunk_assets(
}

fn extract_assets(
all_exposes_sync_chunks: Vec<ModuleId>,
all_exposes_sync_chunks: &[ModuleId],
stats: &StatsJsonMap,
) -> (Vec<String>, Vec<String>) {
all_exposes_sync_chunks.iter().fold(
Expand Down

0 comments on commit b121dbf

Please sign in to comment.