Skip to content
Draft
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
10 changes: 8 additions & 2 deletions crates/next-api/src/project.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@
/// E.g. `/home/user/projects/my-repo`.
pub root_path: RcStr,

/// A path which contains the app/pages directories, relative to [`Project::root_path`], always

Check warning on line 156 in crates/next-api/src/project.rs

View workflow job for this annotation

GitHub Actions / rustdoc check / build

public documentation for `project_path` links to private item `Project::root_path`

Check warning on line 156 in crates/next-api/src/project.rs

View workflow job for this annotation

GitHub Actions / rustdoc check / build

public documentation for `project_path` links to private item `Project::root_path`
/// Unix path. E.g. `apps/my-app`
pub project_path: RcStr,

Expand Down Expand Up @@ -792,7 +792,12 @@

#[turbo_tasks::function]
pub(super) async fn per_page_module_graph(&self) -> Result<Vc<bool>> {
Ok(Vc::cell(*self.mode.await? == NextMode::Development))
Ok(Vc::cell(
!*self
.next_config
.turbo_use_whole_app_module_graph(*self.mode)
.await?,
))
}

#[turbo_tasks::function]
Expand Down Expand Up @@ -996,7 +1001,8 @@
};

// At this point all modules have been computed and we can get rid of the node.js
// process pools
// process pools, in watch mode we don't completely turn it down since we do expect
// invalidations
if *self.is_watch_enabled().await? {
turbopack_node::evaluate::scale_down();
} else {
Expand Down
12 changes: 12 additions & 0 deletions crates/next-core/src/next_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -877,6 +877,7 @@ pub struct ExperimentalConfig {
turbopack_scope_hoisting: Option<bool>,
turbopack_import_type_bytes: Option<bool>,
turbopack_use_system_tls_certs: Option<bool>,
turbopack_use_whole_app_module_graph_in_dev: Option<bool>,
/// Disable automatic configuration of the sass loader.
#[serde(default)]
turbopack_use_builtin_sass: Option<bool>,
Expand Down Expand Up @@ -1840,6 +1841,17 @@ impl NextConfig {
)
}

#[turbo_tasks::function]
pub async fn turbo_use_whole_app_module_graph(&self, mode: Vc<NextMode>) -> Result<Vc<bool>> {
Ok(Vc::cell(match *mode.await? {
NextMode::Development => self
.experimental
.turbopack_use_whole_app_module_graph_in_dev
.unwrap_or(true),
NextMode::Build => true,
}))
}

#[turbo_tasks::function]
pub async fn client_source_maps(&self, mode: Vc<NextMode>) -> Result<Vc<bool>> {
let source_maps = self.experimental.turbopack_source_maps;
Expand Down
1 change: 1 addition & 0 deletions packages/next/src/server/config-schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,7 @@ export const experimentalSchema = {
turbopackUseBuiltinBabel: z.boolean().optional(),
turbopackUseBuiltinSass: z.boolean().optional(),
turbopackModuleIds: z.enum(['named', 'deterministic']).optional(),
turbopackUseWholeAppModuleGraphInDev: z.boolean().optional(),
optimizePackageImports: z.array(z.string()).optional(),
optimizeServerReact: z.boolean().optional(),
clientTraceMetadata: z.array(z.string()).optional(),
Expand Down
6 changes: 6 additions & 0 deletions packages/next/src/server/config-shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -491,6 +491,12 @@ export interface ExperimentalConfig {
*/
turbopackModuleIds?: 'named' | 'deterministic'

/**
* Whether to compute the whole app module graph in development mode. This may reduce memory usage
* by enabling more sharing of chunking decisions across routes.
*/
turbopackUseWholeAppModuleGraphInDev?: boolean

/**
* For use with `@next/mdx`. Compile MDX files using the new Rust compiler.
* @see https://nextjs.org/docs/app/api-reference/next-config-js/mdxRs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ pub struct ChunkingConfigs(FxHashMap<ResolvedVc<Box<dyn ChunkType>>, ChunkingCon
pub trait ChunkingContext {
#[turbo_tasks::function]
fn name(self: Vc<Self>) -> Vc<RcStr>;
/// Whether to use file URIs in source maps.
#[turbo_tasks::function]
fn should_use_file_source_map_uris(self: Vc<Self>) -> Vc<bool>;
/// The root path of the project
Expand Down
Loading