Skip to content
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
11 changes: 9 additions & 2 deletions crates/pack-core/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -241,12 +241,19 @@ pub struct ExternalAdvanced {
pub sub_path: Option<ExternalSubPath>,
}

#[turbo_tasks::value]
#[derive(Clone, Debug, Deserialize, OperationValue)]
#[serde(rename_all = "camelCase")]
pub enum ReactRuntime {
Automatic,
Classic,
}

#[turbo_tasks::value(eq = "manual")]
#[derive(Clone, Debug, PartialEq, Default, Deserialize, OperationValue)]
#[serde(rename_all = "camelCase")]
pub struct ReactConfig {
/// JSX runtime mode: "automatic" (default) or "classic"
pub runtime: Option<RcStr>,
pub runtime: Option<ReactRuntime>,
}

#[turbo_tasks::value(eq = "manual")]
Expand Down
10 changes: 8 additions & 2 deletions crates/pack-core/src/transform_options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ use turbopack_core::{
};
use turbopack_ecmascript::typescript::resolve::{read_from_tsconfigs, read_tsconfigs, tsconfig};

use crate::{config::Config, mode::Mode};
use crate::{
config::{Config, ReactRuntime},
mode::Mode,
};

async fn get_typescript_options(
project_path: FileSystemPath,
Expand Down Expand Up @@ -133,7 +136,10 @@ pub async fn get_jsx_transform_options(
} else {
None
},
runtime: react_config.runtime.clone().or(Some("automatic".into())),
runtime: react_config.runtime.as_ref().map(|runtime| match runtime {
ReactRuntime::Automatic => "automatic".into(),
ReactRuntime::Classic => "classic".into(),
}),
react_refresh: enable_react_refresh,
};

Expand Down
3 changes: 3 additions & 0 deletions packages/pack-shared/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,9 @@ export interface ConfigComplete {
images?: {
inlineLimit?: number;
};
react?: {
runtime?: "automatic" | "classic";
};
stats?: boolean;
persistentCaching?: boolean;
nodePolyfill?: boolean;
Expand Down
Loading