Skip to content

Commit 8ea7984

Browse files
sokraeps1lon
authored andcommitted
Turbopack: avoid depending on the Project (#78730)
### What? avoid depending on the Project value directly, since it will change on every build.
1 parent 1500ec1 commit 8ea7984

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

crates/next-api/src/middleware.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ use crate::{
4444
#[turbo_tasks::value]
4545
pub struct MiddlewareEndpoint {
4646
project: ResolvedVc<Project>,
47-
build_id: RcStr,
4847
asset_context: ResolvedVc<Box<dyn AssetContext>>,
4948
source: ResolvedVc<Box<dyn Source>>,
5049
app_dir: Option<ResolvedVc<FileSystemPath>>,
@@ -56,15 +55,13 @@ impl MiddlewareEndpoint {
5655
#[turbo_tasks::function]
5756
pub fn new(
5857
project: ResolvedVc<Project>,
59-
build_id: RcStr,
6058
asset_context: ResolvedVc<Box<dyn AssetContext>>,
6159
source: ResolvedVc<Box<dyn Source>>,
6260
app_dir: Option<ResolvedVc<FileSystemPath>>,
6361
ecmascript_client_reference_transition_name: Option<ResolvedVc<RcStr>>,
6462
) -> Vc<Self> {
6563
Self {
6664
project,
67-
build_id,
6865
asset_context,
6966
source,
7067
app_dir,

crates/next-api/src/project.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -738,6 +738,11 @@ impl Project {
738738
*self.mode
739739
}
740740

741+
#[turbo_tasks::function]
742+
pub(super) async fn is_watch_enabled(&self) -> Result<Vc<bool>> {
743+
Ok(Vc::cell(self.watch.enable))
744+
}
745+
741746
#[turbo_tasks::function]
742747
pub(super) async fn per_page_module_graph(&self) -> Result<Vc<bool>> {
743748
Ok(Vc::cell(*self.mode.await? == NextMode::Development))
@@ -944,7 +949,7 @@ impl Project {
944949

945950
// At this point all modules have been computed and we can get rid of the node.js
946951
// process pools
947-
if self.await?.watch.enable {
952+
if *self.is_watch_enabled().await? {
948953
turbopack_node::evaluate::scale_down();
949954
} else {
950955
turbopack_node::evaluate::scale_zero();
@@ -1412,7 +1417,6 @@ impl Project {
14121417

14131418
Ok(Vc::upcast(MiddlewareEndpoint::new(
14141419
self,
1415-
self.await?.build_id.clone(),
14161420
middleware_asset_context,
14171421
source,
14181422
app_dir.as_deref().copied(),

0 commit comments

Comments
 (0)