Skip to content

Commit

Permalink
Lints and fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
alexkirsz committed Jul 13, 2023
1 parent ca57e23 commit ac65fd6
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 28 deletions.
2 changes: 1 addition & 1 deletion packages/next-swc/crates/napi/src/next_api/endpoint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ pub async fn endpoint_write_to_disk(
let turbo_tasks = endpoint.turbo_tasks().clone();
let endpoint = **endpoint;
let written = turbo_tasks
.run_once(async move { Ok(endpoint.write_to_disk().strongly_consistent().await?) })
.run_once(endpoint.write_to_disk().strongly_consistent())
.await?;
// TODO peek_issues and diagnostics
Ok((&*written).into())
Expand Down
34 changes: 17 additions & 17 deletions packages/next-swc/crates/napi/src/next_api/project.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use next_api::{
use turbo_tasks::TurboTasks;
use turbopack_binding::turbo::tasks_memory::MemoryBackend;

use super::utils::{serde_enum_to_string, subscribe, RootTask, VcArc};
use super::utils::{serde_enum_to_string, subscribe, NapiDiagnostic, NapiIssue, RootTask, VcArc};
use crate::register;

#[napi(object)]
Expand All @@ -31,14 +31,14 @@ pub struct NapiProjectOptions {
pub memory_limit: Option<f64>,
}

impl Into<ProjectOptions> for NapiProjectOptions {
fn into(self) -> ProjectOptions {
impl From<NapiProjectOptions> for ProjectOptions {
fn from(val: NapiProjectOptions) -> Self {
ProjectOptions {
root_path: self.root_path,
project_path: self.project_path,
watch: self.watch,
next_config: self.next_config,
memory_limit: self.memory_limit.map(|m| m as _),
root_path: val.root_path,
project_path: val.project_path,
watch: val.watch,
next_config: val.next_config,
memory_limit: val.memory_limit.map(|m| m as _),
}
}
}
Expand All @@ -54,7 +54,7 @@ pub async fn project_new(options: NapiProjectOptions) -> napi::Result<External<V
));
let options = options.into();
let project = turbo_tasks
.run_once(async move { Ok(ProjectVc::new(options).resolve().await?) })
.run_once(ProjectVc::new(options).resolve())
.await?;
Ok(External::new_with_size_hint(
VcArc::new(turbo_tasks, project),
Expand Down Expand Up @@ -93,14 +93,14 @@ impl NapiRoute {
} => NapiRoute {
pathname,
r#type: "page",
html_endpoint: convert_endpoint(html_endpoint.clone()),
data_endpoint: convert_endpoint(data_endpoint.clone()),
html_endpoint: convert_endpoint(html_endpoint),
data_endpoint: convert_endpoint(data_endpoint),
..Default::default()
},
Route::PageApi { endpoint } => NapiRoute {
pathname,
r#type: "page-api",
endpoint: convert_endpoint(endpoint.clone()),
endpoint: convert_endpoint(endpoint),
..Default::default()
},
Route::AppPage {
Expand All @@ -109,14 +109,14 @@ impl NapiRoute {
} => NapiRoute {
pathname,
r#type: "app-page",
html_endpoint: convert_endpoint(html_endpoint.clone()),
rsc_endpoint: convert_endpoint(rsc_endpoint.clone()),
html_endpoint: convert_endpoint(html_endpoint),
rsc_endpoint: convert_endpoint(rsc_endpoint),
..Default::default()
},
Route::AppRoute { endpoint } => NapiRoute {
pathname,
r#type: "app-route",
endpoint: convert_endpoint(endpoint.clone()),
endpoint: convert_endpoint(endpoint),
..Default::default()
},
Route::Conflict => NapiRoute {
Expand All @@ -141,7 +141,7 @@ impl NapiMiddleware {
turbo_tasks: &Arc<TurboTasks<MemoryBackend>>,
) -> Result<Self> {
Ok(NapiMiddleware {
endpoint: External::new(VcArc::new(turbo_tasks.clone(), value.endpoint.clone())),
endpoint: External::new(VcArc::new(turbo_tasks.clone(), value.endpoint)),
runtime: serde_enum_to_string(&value.config.runtime)?,
matcher: value.config.matcher.clone(),
})
Expand Down Expand Up @@ -185,7 +185,7 @@ pub fn project_entrypoints_subscribe(
middleware: entrypoints
.middleware
.as_ref()
.map(|m| NapiMiddleware::from_middleware(&m, &turbo_tasks))
.map(|m| NapiMiddleware::from_middleware(m, &turbo_tasks))
.transpose()?,
issues: vec![],
diagnostics: vec![],
Expand Down
4 changes: 3 additions & 1 deletion packages/next-swc/crates/napi/src/next_api/utils.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::{future::Future, ops::Deref, sync::Arc};

use anyhow::{anyhow, bail, Context, Result};
use anyhow::{anyhow, Context, Result};
use napi::{
bindgen_prelude::{External, ToNapiValue},
threadsafe_function::{ThreadSafeCallContext, ThreadsafeFunction, ThreadsafeFunctionCallMode},
Expand Down Expand Up @@ -49,7 +49,9 @@ pub fn serde_enum_to_string<T: Serialize>(value: &T) -> Result<String> {

/// The root of our turbopack computation.
pub struct RootTask {
#[allow(dead_code)]
turbo_tasks: Arc<TurboTasks<MemoryBackend>>,
#[allow(dead_code)]
task_id: Option<TaskId>,
}

Expand Down
11 changes: 3 additions & 8 deletions packages/next-swc/crates/next-api/src/pages.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,8 @@ pub async fn get_pages_routes(
if let Some(page) = pages {
add_dir_to_routes(&mut routes, page, |pathname, original_name, path| {
Route::Page {
html_endpoint: PageHtmlEndpointVc::new(
project,
pathname.clone(),
original_name.clone(),
path,
)
.into(),
html_endpoint: PageHtmlEndpointVc::new(project, pathname, original_name, path)
.into(),
data_endpoint: PageDataEndpointVc::new(project, pathname, original_name, path)
.into(),
}
Expand Down Expand Up @@ -300,7 +295,7 @@ impl Endpoint for PageDataEndpoint {
let this = self_vc.await?;
let ssr_data_chunk = self_vc.ssr_data_chunk();
emit_all_assets(
OutputAssetsVc::cell(vec![ssr_data_chunk.into()]),
OutputAssetsVc::cell(vec![ssr_data_chunk]),
this.project.node_root(),
this.project.client_root().join("_next"),
this.project.node_root(),
Expand Down
2 changes: 1 addition & 1 deletion packages/next-swc/crates/next-api/src/project.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ impl ProjectVc {
}

#[turbo_tasks::function]
async fn node_fs(self) -> Result<DiskFileSystemVc> {
async fn node_fs(self) -> Result<FileSystemVc> {
let this = self.await?;
let disk_fs = DiskFileSystemVc::new("node".to_string(), this.project_path.clone());
disk_fs.await?.start_watching_with_invalidation_reason()?;
Expand Down

0 comments on commit ac65fd6

Please sign in to comment.