From 6d9eb8b6433c27490a7a429f1c7a72fc1354e5d2 Mon Sep 17 00:00:00 2001 From: HeYunfei Date: Thu, 16 Mar 2023 15:43:34 +0800 Subject: [PATCH] fix: contenthash should care about ChunkGraphModule#id (#2292) * fix: contenthash should care about ChunkGraphModule#id * Changeset * Fix error --- .changeset/seven-dancers-melt.md | 5 +++++ crates/rspack_plugin_css/src/plugin.rs | 10 ++++++++-- crates/rspack_plugin_javascript/src/plugin.rs | 12 ++++++++---- 3 files changed, 21 insertions(+), 6 deletions(-) create mode 100644 .changeset/seven-dancers-melt.md diff --git a/.changeset/seven-dancers-melt.md b/.changeset/seven-dancers-melt.md new file mode 100644 index 00000000000..cdc0e256018 --- /dev/null +++ b/.changeset/seven-dancers-melt.md @@ -0,0 +1,5 @@ +--- +"@rspack/binding": patch +--- + +fix: contenthash should care about ChunkGraphModule#id diff --git a/crates/rspack_plugin_css/src/plugin.rs b/crates/rspack_plugin_css/src/plugin.rs index 3e64f4381e0..1deba862f33 100644 --- a/crates/rspack_plugin_css/src/plugin.rs +++ b/crates/rspack_plugin_css/src/plugin.rs @@ -593,10 +593,16 @@ impl Plugin for CssPlugin { ordered_modules .iter() - .map(|module_identifier| compilation.module_graph.get_module_hash(module_identifier)) - .for_each(|current| { + .map(|mgm| { + ( + compilation.module_graph.get_module_hash(mgm), + compilation.chunk_graph.get_module_id(*mgm), + ) + }) + .for_each(|(current, id)| { if let Some(current) = current { current.hash(&mut hasher); + id.hash(&mut hasher); } }); diff --git a/crates/rspack_plugin_javascript/src/plugin.rs b/crates/rspack_plugin_javascript/src/plugin.rs index 4758785f725..86f8e4102ac 100644 --- a/crates/rspack_plugin_javascript/src/plugin.rs +++ b/crates/rspack_plugin_javascript/src/plugin.rs @@ -434,13 +434,17 @@ impl Plugin for JsPlugin { ordered_modules .iter() .map(|mgm| { - compilation - .module_graph - .get_module_hash(&mgm.module_identifier) + ( + compilation + .module_graph + .get_module_hash(&mgm.module_identifier), + compilation.chunk_graph.get_module_id(mgm.module_identifier), + ) }) - .for_each(|current| { + .for_each(|(current, id)| { if let Some(current) = current { current.hash(&mut hasher); + id.hash(&mut hasher); } });