Skip to content

Commit

Permalink
Avoid filename conflict
Browse files Browse the repository at this point in the history
We need to make sure that `.json` and `.json.js` doesn't end up with the same name.
  • Loading branch information
sokra committed Feb 7, 2023
1 parent 9c4d81b commit 9238771
Show file tree
Hide file tree
Showing 19 changed files with 30 additions and 25 deletions.
11 changes: 8 additions & 3 deletions crates/turbopack-core/src/chunk/dev.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,8 @@ impl ChunkingContext for DevChunkingContext {
} else {
clean(&path_vc.to_string().await?)
};
if name.ends_with(extension) {
let removed_extension = name.ends_with(extension);
if removed_extension {
name.truncate(name.len() - extension.len());
}

Expand All @@ -145,9 +146,13 @@ impl ChunkingContext for DevChunkingContext {
let truncated_hash = &hash[..5];
name = format!("{}_{}", truncated_hash, &name[i..]);
}
if !name.ends_with(extension) {
name += extension;
// We need to make sure that `.json` and `.json.js` doesn't end up with the same
// name. So when we add an extra extension when want to mark that with a "._"
// suffix.
if !removed_extension {
name += "._";
}
name += extension;
let mut root_path = self.chunk_root_path;
#[allow(clippy::single_match, reason = "future extensions")]
match extension {
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.

0 comments on commit 9238771

Please sign in to comment.