Skip to content

Commit 02f9ce3

Browse files
committed
turbo recently landed support for assetPrefix and this implements this support for the client reference manifest
1 parent a6f66d9 commit 02f9ce3

File tree

4 files changed

+13
-1
lines changed

4 files changed

+13
-1
lines changed

packages/next-swc/crates/next-api/src/app.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -637,6 +637,10 @@ impl AppEndpoint {
637637
client_references_chunks,
638638
this.app_project.project().client_chunking_context(),
639639
Vc::upcast(this.app_project.project().ssr_chunking_context()),
640+
this.app_project
641+
.project()
642+
.next_config()
643+
.computed_asset_prefix(),
640644
);
641645
server_assets.push(entry_manifest);
642646
}

packages/next-swc/crates/next-build/src/next_app/app_entries.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,7 @@ pub async fn get_app_entries(
239239
/// to `all_chunks`, and the chunking information will be added to the provided
240240
/// manifests.
241241
pub async fn compute_app_entries_chunks(
242+
next_config: Vc<NextConfig>,
242243
app_entries: &AppEntries,
243244
app_client_reference_graph: Vc<ClientReferenceGraph>,
244245
app_client_references_chunks: Vc<ClientReferencesChunks>,
@@ -340,6 +341,7 @@ pub async fn compute_app_entries_chunks(
340341
app_client_references_chunks,
341342
client_chunking_context,
342343
ssr_chunking_context,
344+
next_config.computed_asset_prefix(),
343345
);
344346

345347
all_chunks.push(entry_manifest);

packages/next-swc/crates/next-build/src/next_build.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,7 @@ pub(crate) async fn next_build(options: TransientInstance<BuildOptions>) -> Resu
331331
// TODO(alexkirsz) Do some of that in parallel with the above.
332332

333333
compute_app_entries_chunks(
334+
next_config,
334335
&app_entries,
335336
app_client_references,
336337
app_client_references_chunks,

packages/next-swc/crates/next-core/src/next_manifests/client_reference_manifest.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,14 @@ impl ClientReferenceManifest {
3030
client_references_chunks: Vc<ClientReferencesChunks>,
3131
client_chunking_context: Vc<Box<dyn EcmascriptChunkingContext>>,
3232
ssr_chunking_context: Vc<Box<dyn EcmascriptChunkingContext>>,
33+
asset_prefix: Vc<Option<String>>,
3334
) -> Result<Vc<Box<dyn OutputAsset>>> {
3435
let mut entry_manifest: ClientReferenceManifest = Default::default();
35-
entry_manifest.module_loading.prefix = "/_next/".to_string();
36+
entry_manifest.module_loading.prefix = asset_prefix
37+
.await?
38+
.as_ref()
39+
.map(|p| p.to_owned())
40+
.unwrap_or_default();
3641
entry_manifest.module_loading.cross_origin = None;
3742
let client_references_chunks = client_references_chunks.await?;
3843
let client_relative_path = client_relative_path.await?;

0 commit comments

Comments
 (0)