Skip to content

Commit

Permalink
Configure the React transform development flag
Browse files Browse the repository at this point in the history
  • Loading branch information
alexkirsz committed May 16, 2023
1 parent 7869188 commit 81f5e01
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
5 changes: 4 additions & 1 deletion crates/turbopack-ecmascript/src/transform/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ pub enum EcmascriptInputTransform {
Plugin(TransformPluginVc),
PresetEnv(EnvironmentVc),
React {
#[serde(default)]
development: bool,
#[serde(default)]
refresh: bool,
// swc.jsc.transform.react.importSource
Expand Down Expand Up @@ -143,6 +145,7 @@ impl EcmascriptInputTransform {
} = ctx;
match self {
EcmascriptInputTransform::React {
development,
refresh,
import_source,
runtime,
Expand All @@ -165,7 +168,7 @@ impl EcmascriptInputTransform {

let config = Options {
runtime: Some(runtime),
development: Some(true),
development: Some(*development),
import_source: import_source.await?.clone_value(),
refresh: if *refresh {
Some(swc_core::ecma::transforms::react::RefreshOptions {
Expand Down
1 change: 1 addition & 0 deletions crates/turbopack/src/module_options/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ impl ModuleOptionsVc {
let jsx = enable_jsx.await?;

transforms.push(EcmascriptInputTransform::React {
development: jsx.development,
refresh: jsx.react_refresh,
import_source: OptionStringVc::cell(jsx.import_source.clone()),
runtime: OptionStringVc::cell(jsx.runtime.clone()),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ impl WebpackLoadersOptions {
#[turbo_tasks::value(shared)]
#[derive(Default, Clone, Debug)]
pub struct JsxTransformOptions {
pub development: bool,
pub react_refresh: bool,
pub import_source: Option<String>,
pub runtime: Option<String>,
Expand Down

0 comments on commit 81f5e01

Please sign in to comment.