Skip to content

Commit 4cc56fd

Browse files
committed
add an experimental feature to enable a whole app module graph
1 parent 4a85aab commit 4cc56fd

File tree

4 files changed

+23
-1
lines changed

4 files changed

+23
-1
lines changed

crates/next-api/src/project.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -785,7 +785,12 @@ impl Project {
785785

786786
#[turbo_tasks::function]
787787
pub(super) async fn per_page_module_graph(&self) -> Result<Vc<bool>> {
788-
Ok(Vc::cell(*self.mode.await? == NextMode::Development))
788+
Ok(Vc::cell(
789+
!*self
790+
.next_config
791+
.turbo_use_whole_app_module_graph(*self.mode)
792+
.await?,
793+
))
789794
}
790795

791796
#[turbo_tasks::function]

crates/next-core/src/next_config.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -877,6 +877,7 @@ pub struct ExperimentalConfig {
877877
turbopack_tree_shaking: Option<bool>,
878878
turbopack_scope_hoisting: Option<bool>,
879879
turbopack_use_system_tls_certs: Option<bool>,
880+
turbopack_use_whole_app_module_graph_in_dev: Option<bool>,
880881
/// Disable automatic configuration of the sass loader.
881882
#[serde(default)]
882883
turbopack_use_builtin_sass: Option<bool>,
@@ -1839,6 +1840,16 @@ impl NextConfig {
18391840
}))
18401841
}
18411842

1843+
#[turbo_tasks::function]
1844+
pub async fn turbo_use_whole_app_module_graph(&self, mode: Vc<NextMode>) -> Result<Vc<bool>> {
1845+
Ok(Vc::cell(match *mode.await? {
1846+
NextMode::Development => self
1847+
.experimental
1848+
.turbopack_use_whole_app_module_graph_in_dev
1849+
.unwrap_or(false),
1850+
NextMode::Build => true,
1851+
}))
1852+
}
18421853
#[turbo_tasks::function]
18431854
pub async fn client_source_maps(&self, mode: Vc<NextMode>) -> Result<Vc<bool>> {
18441855
let source_maps = self.experimental.turbopack_source_maps;

packages/next/src/server/config-schema.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -476,6 +476,7 @@ export const configSchema: zod.ZodType<NextConfig> = z.lazy(() =>
476476
turbopackUseSystemTlsCerts: z.boolean().optional(),
477477
turbopackUseBuiltinBabel: z.boolean().optional(),
478478
turbopackUseBuiltinSass: z.boolean().optional(),
479+
turbopackUseWholeAppModuleGraphInDev: z.boolean().optional(),
479480
optimizePackageImports: z.array(z.string()).optional(),
480481
optimizeServerReact: z.boolean().optional(),
481482
clientTraceMetadata: z.array(z.string()).optional(),

packages/next/src/server/config-shared.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -660,6 +660,11 @@ export interface ExperimentalConfig {
660660
*/
661661
turbopackUseBuiltinSass?: boolean
662662

663+
/**
664+
* Whether to use the whole app module graph in development mode. This makes development mode chunking more like production but may come with an HMR performance regression.
665+
*/
666+
turbopackUseWholeAppModuleGraphInDev?: boolean
667+
663668
/**
664669
* For use with `@next/mdx`. Compile MDX files using the new Rust compiler.
665670
* @see https://nextjs.org/docs/app/api-reference/next-config-js/mdxRs

0 commit comments

Comments
 (0)