diff --git a/crates/rspack_core/src/chunk_graph/chunk_graph_module.rs b/crates/rspack_core/src/chunk_graph/chunk_graph_module.rs index c2e519c69f2..9ae1410ef8e 100644 --- a/crates/rspack_core/src/chunk_graph/chunk_graph_module.rs +++ b/crates/rspack_core/src/chunk_graph/chunk_graph_module.rs @@ -196,8 +196,6 @@ impl ChunkGraph { compilation: &Compilation, runtime: Option<&RuntimeSpec>, ) -> u64 { - let mut visited_modules = IdentifierSet::default(); - visited_modules.insert(module.identifier()); let mut hasher = FxHasher::default(); self .get_module_graph_hash_without_connections(module, compilation, runtime) @@ -208,21 +206,25 @@ impl ChunkGraph { .get_outgoing_connections(&module.identifier()) .into_iter() .collect::>(); - for connection in connections { - let module_identifier = connection.module_identifier(); - if visited_modules.contains(module_identifier) { - continue; + if !connections.is_empty() { + let mut visited_modules = IdentifierSet::default(); + visited_modules.insert(module.identifier()); + for connection in connections { + let module_identifier = connection.module_identifier(); + if visited_modules.contains(module_identifier) { + continue; + } + if connection.get_active_state(&mg, runtime).is_false() { + continue; + } + visited_modules.insert(*module_identifier); + let module = mg + .module_by_identifier(module_identifier) + .expect("should have module") + .as_ref(); + module.get_exports_type(&mg, strict).hash(&mut hasher); + self.get_module_graph_hash_without_connections(module, compilation, runtime); } - if connection.get_active_state(&mg, runtime).is_false() { - continue; - } - visited_modules.insert(*module_identifier); - let module = mg - .module_by_identifier(module_identifier) - .expect("should have module") - .as_ref(); - module.get_exports_type(&mg, strict).hash(&mut hasher); - self.get_module_graph_hash_without_connections(module, compilation, runtime); } hasher.finish() } @@ -233,12 +235,14 @@ impl ChunkGraph { compilation: &Compilation, runtime: Option<&RuntimeSpec>, ) -> u64 { - let mg = compilation.get_module_graph(); let mut hasher = FxHasher::default(); - module.identifier().dyn_hash(&mut hasher); + let mg = compilation.get_module_graph(); + let module_identifier = module.identifier(); + let cgm = self.get_chunk_graph_module(module_identifier); + cgm.id.as_ref().dyn_hash(&mut hasher); module.source_types().dyn_hash(&mut hasher); - mg.is_async(&module.identifier()).dyn_hash(&mut hasher); - mg.get_exports_info(&module.identifier()) + mg.is_async(&module_identifier).dyn_hash(&mut hasher); + mg.get_exports_info(&module_identifier) .update_hash(&mg, &mut hasher, compilation, runtime); hasher.finish() } diff --git a/tests/plugin-test/css-extract/cases/content-entries-with-same-import/expected/one_js.$2f93a97aa04d990659bb6450539d9bf9$.css b/tests/plugin-test/css-extract/cases/content-entries-with-same-import/expected/one_js.$4b5109fbbb7c7970bd73f145985a8713$.css similarity index 100% rename from tests/plugin-test/css-extract/cases/content-entries-with-same-import/expected/one_js.$2f93a97aa04d990659bb6450539d9bf9$.css rename to tests/plugin-test/css-extract/cases/content-entries-with-same-import/expected/one_js.$4b5109fbbb7c7970bd73f145985a8713$.css diff --git a/tests/plugin-test/css-extract/cases/content-entries-with-same-import/expected/two_js.$96fc5c6cb322ec288f4a5497b0cedac9$.css b/tests/plugin-test/css-extract/cases/content-entries-with-same-import/expected/two_js.$765cfc26ddecf262088215f69c92da3e$.css similarity index 100% rename from tests/plugin-test/css-extract/cases/content-entries-with-same-import/expected/two_js.$96fc5c6cb322ec288f4a5497b0cedac9$.css rename to tests/plugin-test/css-extract/cases/content-entries-with-same-import/expected/two_js.$765cfc26ddecf262088215f69c92da3e$.css diff --git a/tests/plugin-test/css-extract/cases/contenthash-1/expected/main.$296408a492fdf2232d2d9e34da7e0002$.css b/tests/plugin-test/css-extract/cases/contenthash-1/expected/main.$c414a55a331514d313ce34913a677700$.css similarity index 100% rename from tests/plugin-test/css-extract/cases/contenthash-1/expected/main.$296408a492fdf2232d2d9e34da7e0002$.css rename to tests/plugin-test/css-extract/cases/contenthash-1/expected/main.$c414a55a331514d313ce34913a677700$.css diff --git a/tests/plugin-test/css-extract/cases/contenthash-multiple-entries/expected/entryA.$4d33e3a417f3501849de6198cf874070$.css b/tests/plugin-test/css-extract/cases/contenthash-multiple-entries/expected/entryA.$5038057b5dc54d459c2090d9455373d6$.css similarity index 100% rename from tests/plugin-test/css-extract/cases/contenthash-multiple-entries/expected/entryA.$4d33e3a417f3501849de6198cf874070$.css rename to tests/plugin-test/css-extract/cases/contenthash-multiple-entries/expected/entryA.$5038057b5dc54d459c2090d9455373d6$.css diff --git a/tests/plugin-test/css-extract/cases/contenthash-multiple-entries/expected/entryB.$1aafde33cd7d82fced010e68d76fbb4b$.css b/tests/plugin-test/css-extract/cases/contenthash-multiple-entries/expected/entryB.$8ddf1fb367ac73deeba175a1de156238$.css similarity index 100% rename from tests/plugin-test/css-extract/cases/contenthash-multiple-entries/expected/entryB.$1aafde33cd7d82fced010e68d76fbb4b$.css rename to tests/plugin-test/css-extract/cases/contenthash-multiple-entries/expected/entryB.$8ddf1fb367ac73deeba175a1de156238$.css diff --git a/tests/plugin-test/css-extract/cases/contenthash/expected/1.main.$db8ccfd38278ff640827fcf25338ca6e$.css b/tests/plugin-test/css-extract/cases/contenthash/expected/1.main.$7a92eedfa1f9813bd6a40e1910d3ecc0$.css similarity index 100% rename from tests/plugin-test/css-extract/cases/contenthash/expected/1.main.$db8ccfd38278ff640827fcf25338ca6e$.css rename to tests/plugin-test/css-extract/cases/contenthash/expected/1.main.$7a92eedfa1f9813bd6a40e1910d3ecc0$.css diff --git a/tests/plugin-test/css-extract/cases/contenthash/expected/2.main.$0128dfc0c9cfe270fddcd3f30aad3f61$.css b/tests/plugin-test/css-extract/cases/contenthash/expected/2.main.$4f43297fc0af2c899c5e56fd341c7258$.css similarity index 100% rename from tests/plugin-test/css-extract/cases/contenthash/expected/2.main.$0128dfc0c9cfe270fddcd3f30aad3f61$.css rename to tests/plugin-test/css-extract/cases/contenthash/expected/2.main.$4f43297fc0af2c899c5e56fd341c7258$.css diff --git a/tests/plugin-test/css-extract/cases/issue-6649/expected/main.js b/tests/plugin-test/css-extract/cases/issue-6649/expected/main.js index d279b1c7956..4a43f6e9c50 100644 --- a/tests/plugin-test/css-extract/cases/issue-6649/expected/main.js +++ b/tests/plugin-test/css-extract/cases/issue-6649/expected/main.js @@ -100,14 +100,14 @@ __webpack_require__.e = function (chunkId) { // return url for filenames not based on template // return url for filenames based on template - return "" + chunkId + ".$" + "3c46e7c70e9c35a7c0c2" + "$.css"; + return "" + chunkId + ".$" + "51f879692dc41105d447" + "$.css"; }; })(); // webpack/runtime/get_full_hash (() => { __webpack_require__.h = function () { - return "390adcbb2f3e066ff2d0"; + return "5e241c5760a3e354e528"; }; })(); diff --git a/tests/plugin-test/css-extract/cases/js-hash/expected/style.$e55940b0b8bcba5d5cbdaf4b7684b266$.1.css b/tests/plugin-test/css-extract/cases/js-hash/expected/style.$33888ee88d16a14ff101cdf362266f8f$.1.css similarity index 100% rename from tests/plugin-test/css-extract/cases/js-hash/expected/style.$e55940b0b8bcba5d5cbdaf4b7684b266$.1.css rename to tests/plugin-test/css-extract/cases/js-hash/expected/style.$33888ee88d16a14ff101cdf362266f8f$.1.css diff --git a/tests/plugin-test/css-extract/cases/js-hash/expected/style.$7bc131b60ce1982956ed07f85d4783c6$.2.css b/tests/plugin-test/css-extract/cases/js-hash/expected/style.$cdffad3f0b38fa11c50b5a3ca2766a33$.2.css similarity index 100% rename from tests/plugin-test/css-extract/cases/js-hash/expected/style.$7bc131b60ce1982956ed07f85d4783c6$.2.css rename to tests/plugin-test/css-extract/cases/js-hash/expected/style.$cdffad3f0b38fa11c50b5a3ca2766a33$.2.css