Skip to content

Commit 78f8987

Browse files
authored
include omit entries in hash (vercel/turborepo#3552)
The omit entries need to be included into chunk hashing to avoid conflicting filenames when only omit entries differ
1 parent 316c73e commit 78f8987

File tree

58 files changed

+107
-87
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+107
-87
lines changed

crates/turbo-tasks-hash/src/deterministic_hash.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,12 @@ impl DeterministicHash for &str {
123123
}
124124
}
125125

126+
impl DeterministicHash for bool {
127+
fn deterministic_hash<H: DeterministicHasher>(&self, state: &mut H) {
128+
state.write_u8(*self as u8);
129+
}
130+
}
131+
126132
impl<T: DeterministicHash> DeterministicHash for Option<T> {
127133
fn deterministic_hash<H: DeterministicHasher>(&self, state: &mut H) {
128134
match self {

crates/turbopack-ecmascript/src/chunk/mod.rs

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use turbo_tasks::{
1616
use turbo_tasks_fs::{
1717
embed_file, rope::Rope, File, FileContent, FileSystemPathOptionVc, FileSystemPathVc,
1818
};
19-
use turbo_tasks_hash::{encode_hex, hash_xxh3_hash64, Xxh3Hash64Hasher};
19+
use turbo_tasks_hash::{encode_hex, hash_xxh3_hash64, DeterministicHasher, Xxh3Hash64Hasher};
2020
use turbopack_core::{
2121
asset::{Asset, AssetContentVc, AssetVc},
2222
chunk::{
@@ -969,11 +969,15 @@ impl Asset for EcmascriptChunk {
969969
// evalute only contributes to the hashed info
970970
if let Some(evaluate) = this.evaluate {
971971
let evaluate = evaluate.content(this.context, self_vc).await?;
972-
for path in evaluate.chunks_server_paths.await?.iter() {
972+
let chunks_server_paths = evaluate.chunks_server_paths.await?;
973+
hasher.write_usize(chunks_server_paths.len());
974+
for path in chunks_server_paths.iter() {
973975
hasher.write_ref(path);
974976
need_hash = true;
975977
}
976-
for id in evaluate.entry_modules_ids.await?.iter() {
978+
let entry_modules_ids = evaluate.entry_modules_ids.await?;
979+
hasher.write_usize(entry_modules_ids.len());
980+
for id in entry_modules_ids.iter() {
977981
hasher.write_value(id.await?);
978982
need_hash = true;
979983
}
@@ -986,6 +990,7 @@ impl Asset for EcmascriptChunk {
986990
let main_entry = main_entries.iter().next().unwrap();
987991
main_entry.path()
988992
} else {
993+
hasher.write_usize(main_entries.len());
989994
for entry in &main_entries {
990995
let path = entry.path().to_string().await?;
991996
hasher.write_value(path);
@@ -1001,6 +1006,15 @@ impl Asset for EcmascriptChunk {
10011006
main_entry.path()
10021007
}
10031008
};
1009+
if let Some(omit_entries) = this.omit_entries {
1010+
let omit_entries = omit_entries.await?;
1011+
hasher.write_usize(omit_entries.len());
1012+
for omit_entry in &omit_entries {
1013+
let path = omit_entry.path().to_string().await?;
1014+
hasher.write_value(path);
1015+
}
1016+
need_hash = true;
1017+
}
10041018

10051019
if need_hash {
10061020
let hash = hasher.finish();
Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)