diff --git a/crates/next-core/src/next_client/context.rs b/crates/next-core/src/next_client/context.rs index 78f7be7eb64a..f5ba83d631a1 100644 --- a/crates/next-core/src/next_client/context.rs +++ b/crates/next-core/src/next_client/context.rs @@ -374,6 +374,7 @@ pub async fn get_client_module_options_context( infer_module_side_effects: *next_config.turbopack_infer_module_side_effects().await?, cjs_tree_shaking: *next_config.turbopack_cjs_tree_shaking().await?, cjs_scope_hoisting: *next_config.turbopack_cjs_scope_hoisting().await?, + cross_module_constants: *next_config.turbopack_cross_module_constants().await?, preset_env_config, ..Default::default() }, diff --git a/crates/next-core/src/next_config.rs b/crates/next-core/src/next_config.rs index 8bda61f7b412..be73ae1f64b8 100644 --- a/crates/next-core/src/next_config.rs +++ b/crates/next-core/src/next_config.rs @@ -1443,6 +1443,8 @@ pub struct ExperimentalConfig { turbopack_cjs_tree_shaking: Option, /// Enable scope hoisting of static CommonJS modules. Defaults to false. turbopack_cjs_scope_hoisting: Option, + /// Enable cross-module constant inlining. Defaults to false. + turbopack_cross_module_constants: Option, /// Devtool option for the segment explorer. devtool_segment_explorer: Option, /// Whether to report inlined system environment variables as warnings or errors. @@ -2576,6 +2578,15 @@ impl NextConfig { ) } + #[turbo_tasks::function] + pub fn turbopack_cross_module_constants(&self) -> Vc { + Vc::cell( + self.experimental + .turbopack_cross_module_constants + .unwrap_or(false), + ) + } + #[turbo_tasks::function] pub fn turbopack_plugin_runtime_strategy(&self) -> Vc { #[cfg(feature = "process_pool")] diff --git a/crates/next-core/src/next_server/context.rs b/crates/next-core/src/next_server/context.rs index ab5b57a9405c..f5948109002f 100644 --- a/crates/next-core/src/next_server/context.rs +++ b/crates/next-core/src/next_server/context.rs @@ -549,6 +549,7 @@ pub async fn get_server_module_options_context( infer_module_side_effects: *next_config.turbopack_infer_module_side_effects().await?, cjs_tree_shaking: *next_config.turbopack_cjs_tree_shaking().await?, cjs_scope_hoisting: *next_config.turbopack_cjs_scope_hoisting().await?, + cross_module_constants: *next_config.turbopack_cross_module_constants().await?, ..Default::default() }, execution_context: Some(execution_context), diff --git a/docs/01-app/02-guides/streaming.mdx b/docs/01-app/02-guides/streaming.mdx index a25bbaea0490..4f65f0a32b0e 100644 --- a/docs/01-app/02-guides/streaming.mdx +++ b/docs/01-app/02-guides/streaming.mdx @@ -36,7 +36,7 @@ When a browser requests a page, two streams work together during the initial pag ### The HTML stream -React's server renderer produces progressive HTML chunks. The static parts of your page (layouts, navigation, Suspense fallbacks) render first and are sent immediately. When an async [Server Component](/docs/app/glossary#server-component) resolves, React streams its completed HTML along with inline `