Unverified Commit 7a158475 authored by Niklas Mischkulnig's avatar Niklas Mischkulnig Committed by GitHub

Turbopack: add next_config.use_react_experimental getter (#98032)

Refactor to unify the multiple places where this computation was
happening
parent e3790aa9
...@@ -2429,21 +2429,6 @@ impl NextConfig { ...@@ -2429,21 +2429,6 @@ impl NextConfig {
Vc::cell(self.experimental.taint.unwrap_or(false)) Vc::cell(self.experimental.taint.unwrap_or(false))
} }
#[turbo_tasks::function]
pub fn enable_transition_indicator(&self) -> Vc<bool> {
Vc::cell(self.experimental.transition_indicator.unwrap_or(false))
}
#[turbo_tasks::function]
pub fn enable_gesture_transition(&self) -> Vc<bool> {
Vc::cell(self.experimental.gesture_transition.unwrap_or(false))
}
#[turbo_tasks::function]
pub fn enable_blocking_ssr(&self) -> Vc<bool> {
Vc::cell(self.experimental.blocking_ssr.unwrap_or(false))
}
#[turbo_tasks::function] #[turbo_tasks::function]
pub fn enable_expose_testing_api_in_production_build(&self) -> Vc<bool> { pub fn enable_expose_testing_api_in_production_build(&self) -> Vc<bool> {
Vc::cell( Vc::cell(
...@@ -2486,6 +2471,16 @@ impl NextConfig { ...@@ -2486,6 +2471,16 @@ impl NextConfig {
}) })
} }
#[turbo_tasks::function]
pub fn use_react_experimental(&self) -> Vc<bool> {
// Keep in sync with file:///./../../../packages/next/src/lib/needs-experimental-react.ts
let blocking_ssr = self.experimental.blocking_ssr.unwrap_or(false);
let taint = self.experimental.taint.unwrap_or(false);
let transition_indicator = self.experimental.transition_indicator.unwrap_or(false);
let gesture_transition = self.experimental.gesture_transition.unwrap_or(false);
Vc::cell(blocking_ssr || taint || transition_indicator || gesture_transition)
}
#[turbo_tasks::function] #[turbo_tasks::function]
pub fn is_using_adapter(&self) -> Vc<bool> { pub fn is_using_adapter(&self) -> Vc<bool> {
Vc::cell(self.adapter_path.is_some()) Vc::cell(self.adapter_path.is_some())
......
...@@ -97,13 +97,7 @@ pub async fn get_next_client_import_map( ...@@ -97,13 +97,7 @@ pub async fn get_next_client_import_map(
); );
} }
ClientContextType::App { app_dir } => { ClientContextType::App { app_dir } => {
// Keep in sync with file:///./../../../packages/next/src/lib/needs-experimental-react.ts let react_channel = if *next_config.use_react_experimental().await? {
let blocking_ssr = *next_config.enable_blocking_ssr().await?;
let taint = *next_config.enable_taint().await?;
let transition_indicator = *next_config.enable_transition_indicator().await?;
let gesture_transition = *next_config.enable_gesture_transition().await?;
let react_channel =
if blocking_ssr || taint || transition_indicator || gesture_transition {
"-experimental" "-experimental"
} else { } else {
"" ""
...@@ -883,11 +877,7 @@ async fn apply_vendored_react_aliases_server( ...@@ -883,11 +877,7 @@ async fn apply_vendored_react_aliases_server(
runtime: NextRuntime, runtime: NextRuntime,
next_config: Vc<NextConfig>, next_config: Vc<NextConfig>,
) -> Result<()> { ) -> Result<()> {
let blocking_ssr = *next_config.enable_blocking_ssr().await?; let react_channel = if *next_config.use_react_experimental().await? {
let taint = *next_config.enable_taint().await?;
let transition_indicator = *next_config.enable_transition_indicator().await?;
let gesture_transition = *next_config.enable_gesture_transition().await?;
let react_channel = if blocking_ssr || taint || transition_indicator || gesture_transition {
"-experimental" "-experimental"
} else { } else {
"" ""
......
import type { NextConfig } from '../server/config-shared' import type { NextConfig } from '../server/config-shared'
// Keep in sync with Turbopack's experimental React switch: file://./../../../../crates/next-core/src/next_import_map.rs // Keep in sync with Turbopack's experimental React switch: file://./../../../../crates/next-core/src/next_config.rs
export function needsExperimentalReact(config: NextConfig) { export function needsExperimentalReact(config: NextConfig) {
const { blockingSSR, taint, transitionIndicator, gestureTransition } = const { blockingSSR, taint, transitionIndicator, gestureTransition } =
config.experimental || {} config.experimental || {}
......
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