Skip to content

Turbopack: avoid depending on the Project #78730

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 5, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions crates/next-api/src/middleware.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ use crate::{
#[turbo_tasks::value]
pub struct MiddlewareEndpoint {
project: ResolvedVc<Project>,
build_id: RcStr,
asset_context: ResolvedVc<Box<dyn AssetContext>>,
source: ResolvedVc<Box<dyn Source>>,
app_dir: Option<ResolvedVc<FileSystemPath>>,
Expand All @@ -56,15 +55,13 @@ impl MiddlewareEndpoint {
#[turbo_tasks::function]
pub fn new(
project: ResolvedVc<Project>,
build_id: RcStr,
asset_context: ResolvedVc<Box<dyn AssetContext>>,
source: ResolvedVc<Box<dyn Source>>,
app_dir: Option<ResolvedVc<FileSystemPath>>,
ecmascript_client_reference_transition_name: Option<ResolvedVc<RcStr>>,
) -> Vc<Self> {
Self {
project,
build_id,
asset_context,
source,
app_dir,
Expand Down
8 changes: 6 additions & 2 deletions crates/next-api/src/project.rs
Original file line number Diff line number Diff line change
Expand Up @@ -738,6 +738,11 @@ impl Project {
*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]
pub(super) async fn per_page_module_graph(&self) -> Result<Vc<bool>> {
Ok(Vc::cell(*self.mode.await? == NextMode::Development))
Expand Down Expand Up @@ -944,7 +949,7 @@ impl Project {

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

Ok(Vc::upcast(MiddlewareEndpoint::new(
self,
self.await?.build_id.clone(),
middleware_asset_context,
source,
app_dir.as_deref().copied(),
Expand Down
Loading