Skip to content

Commit 1200e72

Browse files
committed
apply effects in next-build-test
1 parent 563f680 commit 1200e72

File tree

1 file changed

+23
-6
lines changed
  • crates/next-build-test/src

1 file changed

+23
-6
lines changed

crates/next-build-test/src/lib.rs

+23-6
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ use anyhow::{Context, Result};
99
use futures_util::{StreamExt, TryStreamExt};
1010
use next_api::{
1111
project::{ProjectContainer, ProjectOptions},
12-
route::{endpoint_write_to_disk, Route},
12+
route::{endpoint_write_to_disk, Endpoint, EndpointOutputPaths, Route},
1313
};
1414
use turbo_rcstr::RcStr;
15-
use turbo_tasks::{ReadConsistency, TransientInstance, TurboTasks, Vc};
15+
use turbo_tasks::{get_effects, ReadConsistency, ResolvedVc, TransientInstance, TurboTasks, Vc};
1616
use turbo_tasks_backend::{NoopBackingStorage, TurboTasksBackend};
1717
use turbo_tasks_malloc::TurboMalloc;
1818

@@ -185,21 +185,21 @@ pub async fn render_routes(
185185
html_endpoint,
186186
data_endpoint: _,
187187
} => {
188-
endpoint_write_to_disk(*html_endpoint).await?;
188+
endpoint_write_to_disk_with_effects(*html_endpoint).await?;
189189
}
190190
Route::PageApi { endpoint } => {
191-
endpoint_write_to_disk(*endpoint).await?;
191+
endpoint_write_to_disk_with_effects(*endpoint).await?;
192192
}
193193
Route::AppPage(routes) => {
194194
for route in routes {
195-
endpoint_write_to_disk(*route.html_endpoint).await?;
195+
endpoint_write_to_disk_with_effects(*route.html_endpoint).await?;
196196
}
197197
}
198198
Route::AppRoute {
199199
original_name: _,
200200
endpoint,
201201
} => {
202-
endpoint_write_to_disk(*endpoint).await?;
202+
endpoint_write_to_disk_with_effects(*endpoint).await?;
203203
}
204204
Route::Conflict => {
205205
tracing::info!("WARN: conflict {}", name);
@@ -242,6 +242,23 @@ pub async fn render_routes(
242242
Ok(stream.len())
243243
}
244244

245+
#[turbo_tasks::function]
246+
async fn endpoint_write_to_disk_with_effects(
247+
endpoint: ResolvedVc<Box<dyn Endpoint>>,
248+
) -> Result<Vc<EndpointOutputPaths>> {
249+
let op = endpoint_write_to_disk_operation(endpoint);
250+
let result = op.resolve_strongly_consistent().await?;
251+
get_effects(op).await?.apply().await?;
252+
Ok(*result)
253+
}
254+
255+
#[turbo_tasks::function(operation)]
256+
pub fn endpoint_write_to_disk_operation(
257+
endpoint: ResolvedVc<Box<dyn Endpoint>>,
258+
) -> Vc<EndpointOutputPaths> {
259+
endpoint_write_to_disk(*endpoint)
260+
}
261+
245262
async fn hmr(
246263
tt: &TurboTasks<TurboTasksBackend<NoopBackingStorage>>,
247264
project: Vc<ProjectContainer>,

0 commit comments

Comments
 (0)