Skip to content

Turbopack: consistently name runtime chunk #81769

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jul 17, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
1 change: 1 addition & 0 deletions crates/next-api/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1337,6 +1337,7 @@ impl AppEndpoint {
.chunk_path(
Some(Vc::upcast(polyfill_source)),
polyfill_source.ident(),
None,
rcstr!(".js"),
)
.owned()
Expand Down
2 changes: 1 addition & 1 deletion crates/next-core/src/page_loader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ impl OutputAsset for PageLoaderAsset {
} else {
Ok(this
.chunking_context
.chunk_path(Some(Vc::upcast(self)), ident, rcstr!(".js")))
.chunk_path(Some(Vc::upcast(self)), ident, None, rcstr!(".js")))
}
}

Expand Down
7 changes: 6 additions & 1 deletion turbopack/crates/turbopack-browser/src/chunking_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,7 @@ impl ChunkingContext for BrowserChunkingContext {
&self,
asset: Option<Vc<Box<dyn Asset>>>,
ident: Vc<AssetIdent>,
content_hashing_prefix: Option<RcStr>,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe this should be just a prefix in general, even without content hashing

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

extension: RcStr,
) -> Result<Vc<FileSystemPath>> {
debug_assert!(
Expand All @@ -453,7 +454,11 @@ impl ChunkingContext for BrowserChunkingContext {
if let AssetContent::File(file) = &*content {
let hash = hash_xxh3_hash64(&file.await?);
let length = length as usize;
format!("{hash:0length$x}{extension}").into()
if let Some(content_hashing_prefix) = content_hashing_prefix {
format!("{content_hashing_prefix}-{hash:0length$x}{extension}").into()
} else {
format!("{hash:0length$x}{extension}").into()
}
} else {
bail!(
"chunk_path requires an asset with file content when content hashing is \
Expand Down
2 changes: 1 addition & 1 deletion turbopack/crates/turbopack-browser/src/ecmascript/chunk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ impl OutputAsset for EcmascriptBrowserChunk {
let ident = this.ident_for_path();
Ok(this
.chunking_context
.chunk_path(Some(Vc::upcast(self)), ident, rcstr!(".js")))
.chunk_path(Some(Vc::upcast(self)), ident, None, rcstr!(".js")))
}

#[turbo_tasks::function]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -248,9 +248,12 @@ impl OutputAsset for EcmascriptBrowserEvaluateChunk {
async fn path(self: Vc<Self>) -> Result<Vc<FileSystemPath>> {
let this = self.await?;
let ident = self.ident_for_path();
Ok(this
.chunking_context
.chunk_path(Some(Vc::upcast(self)), ident, rcstr!(".js")))
Ok(this.chunking_context.chunk_path(
Some(Vc::upcast(self)),
ident,
Some(rcstr!("turbopack")),
rcstr!(".js"),
))
}

#[turbo_tasks::function]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ impl OutputAsset for EcmascriptDevChunkList {
let ident = AssetIdent::new(ident);
Ok(this
.chunking_context
.chunk_path(Some(Vc::upcast(self)), ident, rcstr!(".js")))
.chunk_path(Some(Vc::upcast(self)), ident, None, rcstr!(".js")))
}

#[turbo_tasks::function]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ pub trait ChunkingContext {
self: Vc<Self>,
asset: Option<Vc<Box<dyn Asset>>>,
ident: Vc<AssetIdent>,
content_hashing_prefix: Option<RcStr>,
extension: RcStr,
) -> Vc<FileSystemPath>;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,12 @@ impl OutputAsset for SourceMapAsset {
chunking_context,
ident_for_path,
} => chunking_context
.chunk_path(Some(Vc::upcast(self)), **ident_for_path, rcstr!(".js"))
.chunk_path(
Some(Vc::upcast(self)),
**ident_for_path,
None,
rcstr!(".js"),
)
.await?
.append(".map")?
.cell(),
Expand Down
10 changes: 6 additions & 4 deletions turbopack/crates/turbopack-css/src/chunk/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -329,10 +329,12 @@ impl OutputAsset for CssChunk {
async fn path(self: Vc<Self>) -> Result<Vc<FileSystemPath>> {
let ident = self.ident_for_path();

Ok(self
.await?
.chunking_context
.chunk_path(Some(Vc::upcast(self)), ident, rcstr!(".css")))
Ok(self.await?.chunking_context.chunk_path(
Some(Vc::upcast(self)),
ident,
None,
rcstr!(".css"),
))
}

#[turbo_tasks::function]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ impl OutputAsset for SingleItemCssChunk {
Ok(self.await?.chunking_context.chunk_path(
Some(Vc::upcast(self)),
self.ident_for_path(),
None,
rcstr!(".single.css"),
))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ impl OutputAsset for SingleItemCssChunkSourceMapAsset {
.chunk_path(
Some(Vc::upcast(self)),
this.chunk.ident_for_path(),
None,
".single.css".into(),
)
.await?
Expand Down
2 changes: 1 addition & 1 deletion turbopack/crates/turbopack-css/src/chunk/source_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ impl OutputAsset for CssChunkSourceMapAsset {
.chunk
.await?
.chunking_context
.chunk_path(Some(Vc::upcast(self)), ident, ".css".into())
.chunk_path(Some(Vc::upcast(self)), ident, None, ".css".into())
.await?
.append(".map")?
.cell())
Expand Down
2 changes: 1 addition & 1 deletion turbopack/crates/turbopack-node/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ pub async fn get_intermediate_asset(
Ok(Vc::upcast(
chunking_context.root_entry_chunk_group_asset(
chunking_context
.chunk_path(None, main_entry.ident(), rcstr!(".js"))
.chunk_path(None, main_entry.ident(), None, rcstr!(".js"))
.owned()
.await?,
other_entries.with_entry(*main_entry),
Expand Down
1 change: 1 addition & 0 deletions turbopack/crates/turbopack-nodejs/src/chunking_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,7 @@ impl ChunkingContext for NodeJsChunkingContext {
&self,
_asset: Option<Vc<Box<dyn Asset>>>,
ident: Vc<AssetIdent>,
_content_hashing_prefix: Option<RcStr>,
extension: RcStr,
) -> Result<Vc<FileSystemPath>> {
let root_path = self.chunk_root_path.clone();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ impl OutputAsset for EcmascriptBuildNodeChunk {
let ident = this.chunk.ident().with_modifier(modifier());
Ok(this
.chunking_context
.chunk_path(Some(Vc::upcast(self)), ident, rcstr!(".js")))
.chunk_path(Some(Vc::upcast(self)), ident, None, rcstr!(".js")))
}

#[turbo_tasks::function]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ impl OutputAsset for EcmascriptBuildNodeRuntimeChunk {

Ok(this
.chunking_context
.chunk_path(Some(Vc::upcast(self)), ident, rcstr!(".js")))
.chunk_path(Some(Vc::upcast(self)), ident, None, rcstr!(".js")))
}

#[turbo_tasks::function]
Expand Down
2 changes: 1 addition & 1 deletion turbopack/crates/turbopack-wasm/src/output_asset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ impl OutputAsset for WebAssemblyAsset {
let ident = this.source.ident().with_modifier(rcstr!("wasm"));
Ok(this
.chunking_context
.chunk_path(Some(Vc::upcast(self)), ident, rcstr!(".wasm")))
.chunk_path(Some(Vc::upcast(self)), ident, None, rcstr!(".wasm")))
}
}

Expand Down
Loading