Skip to content

Commit

Permalink
fix(Hash-376): Hash should not be applied on inline.js (#377)
Browse files Browse the repository at this point in the history
Changes:
- Do not hash inline.js files as it will break the imports when using the webassembly in the frontend
- When hashing files, if the file is within snippets is called inline and has an extension of .js then do not hash it
  • Loading branch information
DennisJensen95 authored Oct 23, 2024
1 parent 14e0acc commit 25f184b
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/compile/hash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,25 @@ fn compute_front_file_hashes(proj: &Project) -> Result<HashMap<Utf8PathBuf, Stri
}
}

// Check if the path contains snippets and also if it
// contains inline{}.js. We do not want to hash these files
// as the webassembly will look for an unhashed version of
// the .js file. The folder though can be hashed.
if let Some(path_str) = path.to_str() {
if path_str.contains("snippets") {
if let Some(file_name) = path.file_name() {
let file_name_str = file_name.to_string_lossy();
if file_name_str.contains("inline") {
if let Some(extension) = path.extension() {
if extension == "js" {
continue;
}
}
}
}
}
}

let hash = Base64UrlUnpadded::encode_string(
&Md5::new().chain_update(fs::read(&path)?).finalize(),
);
Expand Down

0 comments on commit 25f184b

Please sign in to comment.