Skip to content

Commit

Permalink
Remove rust-side changes for runtime() api that is removed.
Browse files Browse the repository at this point in the history
  • Loading branch information
timneutkens authored and mischnic committed Feb 3, 2025
1 parent 1f5e43b commit b026c32
Show file tree
Hide file tree
Showing 6 changed files with 5 additions and 72 deletions.
16 changes: 1 addition & 15 deletions crates/next-api/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,7 @@ use crate::{
get_wasm_paths_from_root, paths_to_bindings, wasm_paths_to_bindings,
},
project::{ModuleGraphs, Project},
route::{
AppPageRoute, Endpoint, EndpointOutput, EndpointOutputPaths, EndpointRuntime, Route, Routes,
},
route::{AppPageRoute, Endpoint, EndpointOutput, EndpointOutputPaths, Route, Routes},
server_actions::{build_server_actions_loader, create_server_actions_manifest},
webpack_stats::generate_webpack_stats,
};
Expand Down Expand Up @@ -1794,18 +1792,6 @@ async fn create_app_paths_manifest(

#[turbo_tasks::value_impl]
impl Endpoint for AppEndpoint {
#[turbo_tasks::function]
async fn runtime(self: ResolvedVc<Self>) -> Result<Vc<EndpointRuntime>> {
let app_entry = self.app_endpoint_entry().await?;
let runtime = app_entry.config.await?.runtime.unwrap_or_default();

Ok(match runtime {
NextRuntime::Edge => EndpointRuntime::Edge,
NextRuntime::NodeJs => EndpointRuntime::NodeJs,
}
.cell())
}

#[turbo_tasks::function]
async fn output(self: ResolvedVc<Self>) -> Result<Vc<EndpointOutput>> {
let this = self.await?;
Expand Down
7 changes: 1 addition & 6 deletions crates/next-api/src/empty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use anyhow::{bail, Result};
use turbo_tasks::{Completion, Vc};
use turbopack_core::module::Modules;

use crate::route::{Endpoint, EndpointOutput, EndpointRuntime};
use crate::route::{Endpoint, EndpointOutput};

#[turbo_tasks::value]
pub struct EmptyEndpoint;
Expand All @@ -17,11 +17,6 @@ impl EmptyEndpoint {

#[turbo_tasks::value_impl]
impl Endpoint for EmptyEndpoint {
#[turbo_tasks::function]
fn runtime(self: Vc<Self>) -> Result<Vc<EndpointRuntime>> {
bail!("Empty endpoint can't have runtime")
}

#[turbo_tasks::function]
fn output(self: Vc<Self>) -> Result<Vc<EndpointOutput>> {
bail!("Empty endpoint can't have output")
Expand Down
7 changes: 1 addition & 6 deletions crates/next-api/src/instrumentation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ use crate::{
all_server_paths, get_js_paths_from_root, get_wasm_paths_from_root, wasm_paths_to_bindings,
},
project::Project,
route::{Endpoint, EndpointOutput, EndpointOutputPaths, EndpointRuntime},
route::{Endpoint, EndpointOutput, EndpointOutputPaths},
};

#[turbo_tasks::value]
Expand Down Expand Up @@ -248,11 +248,6 @@ struct InstrumentationCoreModules {

#[turbo_tasks::value_impl]
impl Endpoint for InstrumentationEndpoint {
#[turbo_tasks::function]
async fn runtime(self: ResolvedVc<Self>) -> Vc<EndpointRuntime> {
EndpointRuntime::Edge.cell()
}

#[turbo_tasks::function]
async fn output(self: ResolvedVc<Self>) -> Result<Vc<EndpointOutput>> {
let span = tracing::info_span!("instrumentation endpoint");
Expand Down
7 changes: 1 addition & 6 deletions crates/next-api/src/middleware.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ use crate::{
get_wasm_paths_from_root, paths_to_bindings, wasm_paths_to_bindings,
},
project::Project,
route::{Endpoint, EndpointOutput, EndpointOutputPaths, EndpointRuntime},
route::{Endpoint, EndpointOutput, EndpointOutputPaths},
};

#[turbo_tasks::value]
Expand Down Expand Up @@ -276,11 +276,6 @@ impl MiddlewareEndpoint {

#[turbo_tasks::value_impl]
impl Endpoint for MiddlewareEndpoint {
#[turbo_tasks::function]
async fn runtime(self: ResolvedVc<Self>) -> Vc<EndpointRuntime> {
EndpointRuntime::Edge.cell()
}

#[turbo_tasks::function]
async fn output(self: ResolvedVc<Self>) -> Result<Vc<EndpointOutput>> {
let span = tracing::info_span!("middleware endpoint");
Expand Down
32 changes: 1 addition & 31 deletions crates/next-api/src/pages.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ use crate::{
get_wasm_paths_from_root, paths_to_bindings, wasm_paths_to_bindings,
},
project::Project,
route::{Endpoint, EndpointOutput, EndpointOutputPaths, EndpointRuntime, Route, Routes},
route::{Endpoint, EndpointOutput, EndpointOutputPaths, Route, Routes},
webpack_stats::generate_webpack_stats,
};

Expand Down Expand Up @@ -1373,36 +1373,6 @@ pub struct InternalSsrChunkModule {

#[turbo_tasks::value_impl]
impl Endpoint for PageEndpoint {
#[turbo_tasks::function]
async fn runtime(self: Vc<Self>) -> Result<Vc<EndpointRuntime>> {
let this = &*self.await?;
let (reference_type, module_context) = match this.ty {
PageEndpointType::Html | PageEndpointType::SsrOnly => (
Value::new(ReferenceType::Entry(EntryReferenceSubType::Page)),
this.pages_project.ssr_module_context(),
),
PageEndpointType::Data => (
Value::new(ReferenceType::Entry(EntryReferenceSubType::Page)),
this.pages_project.ssr_data_module_context(),
),
PageEndpointType::Api => (
Value::new(ReferenceType::Entry(EntryReferenceSubType::PagesApi)),
this.pages_project.api_module_context(),
),
};

let ssr_module = module_context
.process(self.source(), reference_type.clone())
.module();

let config = parse_config_from_source(ssr_module).await?;
Ok(match config.runtime {
NextRuntime::NodeJs => EndpointRuntime::NodeJs,
NextRuntime::Edge => EndpointRuntime::Edge,
}
.cell())
}

#[turbo_tasks::function]
async fn output(self: ResolvedVc<Self>) -> Result<Vc<EndpointOutput>> {
let this = self.await?;
Expand Down
8 changes: 0 additions & 8 deletions crates/next-api/src/route.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,8 @@ pub enum Route {
Conflict,
}

#[derive(Copy, Clone)]
#[turbo_tasks::value(shared)]
pub enum EndpointRuntime {
NodeJs,
Edge,
}

#[turbo_tasks::value_trait]
pub trait Endpoint {
fn runtime(self: Vc<Self>) -> Vc<EndpointRuntime>;
fn output(self: Vc<Self>) -> Vc<EndpointOutput>;
// fn write_to_disk(self: Vc<Self>) -> Vc<EndpointOutputPaths>;
fn server_changed(self: Vc<Self>) -> Vc<Completion>;
Expand Down

0 comments on commit b026c32

Please sign in to comment.