Skip to content

Commit

Permalink
include omit entries in hash (#3552)
Browse files Browse the repository at this point in the history
The omit entries need to be included into chunk hashing to avoid
conflicting filenames when only omit entries differ
  • Loading branch information
sokra authored and mehulkar committed Feb 1, 2023
1 parent 35df145 commit a3448b1
Show file tree
Hide file tree
Showing 58 changed files with 107 additions and 87 deletions.
6 changes: 6 additions & 0 deletions crates/turbo-tasks-hash/src/deterministic_hash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,12 @@ impl DeterministicHash for &str {
}
}

impl DeterministicHash for bool {
fn deterministic_hash<H: DeterministicHasher>(&self, state: &mut H) {
state.write_u8(*self as u8);
}
}

impl<T: DeterministicHash> DeterministicHash for Option<T> {
fn deterministic_hash<H: DeterministicHasher>(&self, state: &mut H) {
match self {
Expand Down
20 changes: 17 additions & 3 deletions crates/turbopack-ecmascript/src/chunk/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use turbo_tasks::{
use turbo_tasks_fs::{
embed_file, rope::Rope, File, FileContent, FileSystemPathOptionVc, FileSystemPathVc,
};
use turbo_tasks_hash::{encode_hex, hash_xxh3_hash64, Xxh3Hash64Hasher};
use turbo_tasks_hash::{encode_hex, hash_xxh3_hash64, DeterministicHasher, Xxh3Hash64Hasher};
use turbopack_core::{
asset::{Asset, AssetContentVc, AssetVc},
chunk::{
Expand Down Expand Up @@ -969,11 +969,15 @@ impl Asset for EcmascriptChunk {
// evalute only contributes to the hashed info
if let Some(evaluate) = this.evaluate {
let evaluate = evaluate.content(this.context, self_vc).await?;
for path in evaluate.chunks_server_paths.await?.iter() {
let chunks_server_paths = evaluate.chunks_server_paths.await?;
hasher.write_usize(chunks_server_paths.len());
for path in chunks_server_paths.iter() {
hasher.write_ref(path);
need_hash = true;
}
for id in evaluate.entry_modules_ids.await?.iter() {
let entry_modules_ids = evaluate.entry_modules_ids.await?;
hasher.write_usize(entry_modules_ids.len());
for id in entry_modules_ids.iter() {
hasher.write_value(id.await?);
need_hash = true;
}
Expand All @@ -986,6 +990,7 @@ impl Asset for EcmascriptChunk {
let main_entry = main_entries.iter().next().unwrap();
main_entry.path()
} else {
hasher.write_usize(main_entries.len());
for entry in &main_entries {
let path = entry.path().to_string().await?;
hasher.write_value(path);
Expand All @@ -1001,6 +1006,15 @@ impl Asset for EcmascriptChunk {
main_entry.path()
}
};
if let Some(omit_entries) = this.omit_entries {
let omit_entries = omit_entries.await?;
hasher.write_usize(omit_entries.len());
for omit_entry in &omit_entries {
let path = omit_entry.path().to_string().await?;
hasher.write_value(path);
}
need_hash = true;
}

if need_hash {
let hash = hasher.finish();
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit a3448b1

Please sign in to comment.