Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion turbopack/crates/turbopack-css/src/chunk/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ impl CssChunk {

let mut hasher = Xxh3Hash64Hasher::new();
chunk_item_idents.iter().for_each(|ident| {
hasher.write_value(ident.as_str());
ident.ddeterministic_hash(&mut hash);
});

let hash = hasher.finish();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ function normalizeChunkPath(path: string) {
return path;
}

const NORMED_CHUNK_BASE_PATH = normalizeChunkPath(CHUNK_BASE_PATH);
const NORMED_CHUNK_SUFFIX_PATH = normalizeChunkPath(CHUNK_SUFFIX_PATH);
const NORMALIZED_CHUNK_BASE_PATH = normalizeChunkPath(CHUNK_BASE_PATH);
const NORMALIZED_CHUNK_SUFFIX_PATH = normalizeChunkPath(CHUNK_SUFFIX_PATH);

// Provided by build or dev base
declare function instantiateModule(id: ModuleId, source: SourceInfo): Module;
Expand Down Expand Up @@ -321,10 +321,10 @@ function instantiateRuntimeModule(
* Returns the URL relative to the origin where a chunk can be fetched from.
*/
function getChunkRelativeUrl(chunkPath: ChunkPath | ChunkListPath): ChunkUrl {
return `${NORMED_CHUNK_BASE_PATH}${chunkPath
return `${NORMALIZED_CHUNK_BASE_PATH}${chunkPath
.split("/")
.map((p) => encodeURIComponent(p))
.join("/")}${NORMED_CHUNK_SUFFIX_PATH}` as ChunkUrl;
.join("/")}${NORMALIZED_CHUNK_SUFFIX_PATH}` as ChunkUrl;
}

/**
Expand All @@ -343,7 +343,7 @@ function getPathFromScript(chunkScript: ChunkPath | ChunkListPath | ChunkScript
chunkUrl = chunkUrl.substring(2);
}
const src = decodeURIComponent(chunkUrl.replace(/[?#].*$/, ""));
const path = src.startsWith(NORMED_CHUNK_BASE_PATH) ? src.slice(NORMED_CHUNK_BASE_PATH.length) : src;
const path = src.startsWith(NORMALIZED_CHUNK_BASE_PATH) ? src.slice(NORMALIZED_CHUNK_BASE_PATH.length) : src;
return path as ChunkPath | ChunkListPath;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ let DEV_BACKEND: DevRuntimeBackend;

function _eval({ code, url, map }: EcmascriptModuleEntry): ModuleFactory {
code += `\n\n//# sourceURL=${encodeURI(
location.origin + NORMED_CHUNK_BASE_PATH + normalizeChunPath(url) + NORMED_CHUNK_SUFFIX_PATH
location.origin + NORMALIZED_CHUNK_BASE_PATH + normalizeChunkPath(url) + NORMALIZED_CHUNK_SUFFIX_PATH
)}`;
if (map) {
code += `\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,${btoa(
Expand Down
4 changes: 2 additions & 2 deletions turbopack/crates/turbopack-ecmascript/src/chunk/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use anyhow::Result;
use turbo_rcstr::RcStr;
use turbo_tasks::{ResolvedVc, TryFlatJoinIterExt, TryJoinIterExt, Value, ValueToString, Vc};
use turbo_tasks_fs::FileSystem;
use turbo_tasks_hash::{encode_hex, Xxh3Hash64Hasher};
use turbo_tasks_hash::{encode_hex, DeterministicHash, Xxh3Hash64Hasher};
use turbopack_core::{
chunk::{Chunk, ChunkItem, ChunkItems, ChunkingContext, ModuleIds},
ident::AssetIdent,
Expand Down Expand Up @@ -94,7 +94,7 @@ impl Chunk for EcmascriptChunk {

let mut hasher = Xxh3Hash64Hasher::new();
chunk_item_idents.iter().for_each(|ident| {
hasher.write_value(ident.as_str());
ident.deterministic_hash(&mut hasher);
});

let hash = hasher.finish();
Expand Down
Loading