Unverified Commit e72a76e4 authored by Tobias Koppers's avatar Tobias Koppers Committed by GitHub

Turbopack: avoid depending on the Project (#78730)

### What?

avoid depending on the Project value directly, since it will change on
every build.
parent ad399701
...@@ -44,7 +44,6 @@ use crate::{ ...@@ -44,7 +44,6 @@ use crate::{
#[turbo_tasks::value] #[turbo_tasks::value]
pub struct MiddlewareEndpoint { pub struct MiddlewareEndpoint {
project: ResolvedVc<Project>, project: ResolvedVc<Project>,
build_id: RcStr,
asset_context: ResolvedVc<Box<dyn AssetContext>>, asset_context: ResolvedVc<Box<dyn AssetContext>>,
source: ResolvedVc<Box<dyn Source>>, source: ResolvedVc<Box<dyn Source>>,
app_dir: Option<ResolvedVc<FileSystemPath>>, app_dir: Option<ResolvedVc<FileSystemPath>>,
...@@ -56,7 +55,6 @@ impl MiddlewareEndpoint { ...@@ -56,7 +55,6 @@ impl MiddlewareEndpoint {
#[turbo_tasks::function] #[turbo_tasks::function]
pub fn new( pub fn new(
project: ResolvedVc<Project>, project: ResolvedVc<Project>,
build_id: RcStr,
asset_context: ResolvedVc<Box<dyn AssetContext>>, asset_context: ResolvedVc<Box<dyn AssetContext>>,
source: ResolvedVc<Box<dyn Source>>, source: ResolvedVc<Box<dyn Source>>,
app_dir: Option<ResolvedVc<FileSystemPath>>, app_dir: Option<ResolvedVc<FileSystemPath>>,
...@@ -64,7 +62,6 @@ impl MiddlewareEndpoint { ...@@ -64,7 +62,6 @@ impl MiddlewareEndpoint {
) -> Vc<Self> { ) -> Vc<Self> {
Self { Self {
project, project,
build_id,
asset_context, asset_context,
source, source,
app_dir, app_dir,
......
...@@ -738,6 +738,11 @@ impl Project { ...@@ -738,6 +738,11 @@ impl Project {
*self.mode *self.mode
} }
#[turbo_tasks::function]
pub(super) async fn is_watch_enabled(&self) -> Result<Vc<bool>> {
Ok(Vc::cell(self.watch.enable))
}
#[turbo_tasks::function] #[turbo_tasks::function]
pub(super) async fn per_page_module_graph(&self) -> Result<Vc<bool>> { pub(super) async fn per_page_module_graph(&self) -> Result<Vc<bool>> {
Ok(Vc::cell(*self.mode.await? == NextMode::Development)) Ok(Vc::cell(*self.mode.await? == NextMode::Development))
...@@ -944,7 +949,7 @@ impl Project { ...@@ -944,7 +949,7 @@ impl Project {
// At this point all modules have been computed and we can get rid of the node.js // At this point all modules have been computed and we can get rid of the node.js
// process pools // process pools
if self.await?.watch.enable { if *self.is_watch_enabled().await? {
turbopack_node::evaluate::scale_down(); turbopack_node::evaluate::scale_down();
} else { } else {
turbopack_node::evaluate::scale_zero(); turbopack_node::evaluate::scale_zero();
...@@ -1412,7 +1417,6 @@ impl Project { ...@@ -1412,7 +1417,6 @@ impl Project {
Ok(Vc::upcast(MiddlewareEndpoint::new( Ok(Vc::upcast(MiddlewareEndpoint::new(
self, self,
self.await?.build_id.clone(),
middleware_asset_context, middleware_asset_context,
source, source,
app_dir.as_deref().copied(), app_dir.as_deref().copied(),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment