From 459dbde69790cdd8dd02b804c745ae67f9d2c952 Mon Sep 17 00:00:00 2001 From: Jonathan Kelley Date: Tue, 17 Sep 2024 17:47:41 -0700 Subject: [PATCH] Fix bug in js bundle --- packages/lazy-js-bundle/src/lib.rs | 34 +++++++----------------------- 1 file changed, 8 insertions(+), 26 deletions(-) diff --git a/packages/lazy-js-bundle/src/lib.rs b/packages/lazy-js-bundle/src/lib.rs index 36dae8da4..ce48d1ae9 100644 --- a/packages/lazy-js-bundle/src/lib.rs +++ b/packages/lazy-js-bundle/src/lib.rs @@ -79,32 +79,14 @@ impl LazyTypeScriptBindings { // Compute the hash of the input files let hashes = hash_files(watching_paths); - // Try to find a common prefix for the output files and put the hash in there otherwise, write it to src/binding_hash.txt - let mut hash_location: Option = None; - for path in &self.binding { - match hash_location { - Some(current_hash_location) => { - let mut common_path = PathBuf::new(); - for component in path - .output_path - .components() - .zip(current_hash_location.components()) - { - if component.0 != component.1 { - break; - } - common_path.push(component.0); - } - hash_location = - (common_path.components().next().is_some()).then_some(common_path); - } - None => { - hash_location = Some(path.output_path.clone()); - } - }; - } - let hash_location = hash_location.unwrap_or_else(|| PathBuf::from("./src/js")); - std::fs::create_dir_all(&hash_location).unwrap(); + let hash_location = PathBuf::from("./src/js/"); + std::fs::create_dir_all(&hash_location).unwrap_or_else(|err| { + panic!( + "Failed to create directory for hash file: {} in {}", + err, + hash_location.display() + ) + }); let hash_location = hash_location.join("hash.txt"); // If the hash matches the one on disk, we're good and don't need to update bindings