diff --git a/crates/next-api/src/app.rs b/crates/next-api/src/app.rs index 0bb5248a4de4d..273c7c544855b 100644 --- a/crates/next-api/src/app.rs +++ b/crates/next-api/src/app.rs @@ -1638,17 +1638,28 @@ impl Endpoint for AppEndpoint { .project() .emit_all_output_assets(Vc::cell(output_assets)); - let node_root = this.app_project.project().node_root(); - let server_paths = all_server_paths(output_assets, node_root) + let (server_paths, client_paths) = if this + .app_project + .project() + .next_mode() .await? - .clone_value(); + .is_development() + { + let node_root = this.app_project.project().node_root(); + let server_paths = all_server_paths(output_assets, node_root) + .await? + .clone_value(); - let client_relative_root = this.app_project.project().client_relative_path(); - let client_paths = all_paths_in_root(output_assets, client_relative_root) - .into_future() - .instrument(tracing::info_span!("client_paths")) - .await? - .clone_value(); + let client_relative_root = this.app_project.project().client_relative_path(); + let client_paths = all_paths_in_root(output_assets, client_relative_root) + .into_future() + .instrument(tracing::info_span!("client_paths")) + .await? + .clone_value(); + (server_paths, client_paths) + } else { + (vec![], vec![]) + }; let written_endpoint = match *output { AppEndpointOutput::NodeJs { rsc_chunk, .. } => WrittenEndpoint::NodeJs { diff --git a/crates/next-api/src/instrumentation.rs b/crates/next-api/src/instrumentation.rs index e01514c3631bc..ef76071d2ea76 100644 --- a/crates/next-api/src/instrumentation.rs +++ b/crates/next-api/src/instrumentation.rs @@ -252,10 +252,14 @@ impl Endpoint for InstrumentationEndpoint { let _ = output_assets.resolve().await?; let _ = this.project.emit_all_output_assets(Vc::cell(output_assets)); - let node_root = this.project.node_root(); - let server_paths = all_server_paths(output_assets, node_root) - .await? - .clone_value(); + let server_paths = if this.project.next_mode().await?.is_development() { + let node_root = this.project.node_root(); + all_server_paths(output_assets, node_root) + .await? + .clone_value() + } else { + vec![] + }; Ok(WrittenEndpoint::Edge { server_paths, diff --git a/crates/next-api/src/middleware.rs b/crates/next-api/src/middleware.rs index a1bd72470654a..2d700046c94bd 100644 --- a/crates/next-api/src/middleware.rs +++ b/crates/next-api/src/middleware.rs @@ -279,18 +279,23 @@ impl Endpoint for MiddlewareEndpoint { let _ = output_assets.resolve().await?; let _ = this.project.emit_all_output_assets(Vc::cell(output_assets)); - let node_root = this.project.node_root(); - let server_paths = all_server_paths(output_assets, node_root) - .await? - .clone_value(); - - // Middleware could in theory have a client path (e.g. `new URL`). - let client_relative_root = this.project.client_relative_path(); - let client_paths = all_paths_in_root(output_assets, client_relative_root) - .into_future() - .instrument(tracing::info_span!("client_paths")) - .await? - .clone_value(); + let (server_paths, client_paths) = if this.project.next_mode().await?.is_development() { + let node_root = this.project.node_root(); + let server_paths = all_server_paths(output_assets, node_root) + .await? + .clone_value(); + + // Middleware could in theory have a client path (e.g. `new URL`). + let client_relative_root = this.project.client_relative_path(); + let client_paths = all_paths_in_root(output_assets, client_relative_root) + .into_future() + .instrument(tracing::info_span!("client_paths")) + .await? + .clone_value(); + (server_paths, client_paths) + } else { + (vec![], vec![]) + }; Ok(WrittenEndpoint::Edge { server_paths, diff --git a/crates/next-api/src/pages.rs b/crates/next-api/src/pages.rs index 7e974c15229ed..313cef1caef88 100644 --- a/crates/next-api/src/pages.rs +++ b/crates/next-api/src/pages.rs @@ -1275,16 +1275,28 @@ impl Endpoint for PageEndpoint { .emit_all_output_assets(Vc::cell(output_assets)); let node_root = this.pages_project.project().node_root(); - let server_paths = all_server_paths(output_assets, node_root) - .await? - .clone_value(); - let client_relative_root = this.pages_project.project().client_relative_path(); - let client_paths = all_paths_in_root(output_assets, client_relative_root) - .into_future() - .instrument(tracing::info_span!("client_paths")) + let (server_paths, client_paths) = if this + .pages_project + .project() + .next_mode() .await? - .clone_value(); + .is_development() + { + let server_paths = all_server_paths(output_assets, node_root) + .await? + .clone_value(); + + let client_relative_root = this.pages_project.project().client_relative_path(); + let client_paths = all_paths_in_root(output_assets, client_relative_root) + .into_future() + .instrument(tracing::info_span!("client_paths")) + .await? + .clone_value(); + (server_paths, client_paths) + } else { + (vec![], vec![]) + }; let node_root = &node_root.await?; let written_endpoint = match *output {