Skip to content

Commit

Permalink
feat(plugin-react): assign runtime default value is automatic (#1249
Browse files Browse the repository at this point in the history
)

* feat(plugin-react): assign `runtime` default value is `automatic`

* chore(plugin-react): fix lint

* chore(changeset): update

* chore(changeset): update

---------

Co-authored-by: brightwu <[email protected]>
  • Loading branch information
yejimeiming and wre232114 committed Apr 27, 2024
1 parent 7d93c71 commit a9b5db7
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .changeset/unlucky-bugs-brush.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@farmfe/plugin-react': minor
---

assign `runtime` default value is `automatic`
7 changes: 6 additions & 1 deletion crates/node/src/plugin_toolkit/swc_transforms.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use farmfe_toolkit::{
script::swc_try_with::try_with,
swc_ecma_transforms::{
helpers::inject_helpers,
react::{react, Options, RefreshOptions},
react::{react, Options, RefreshOptions, Runtime},
},
swc_ecma_visit::VisitMutWith,
};
Expand Down Expand Up @@ -44,6 +44,11 @@ pub fn farm_swc_transform_react(
None
},
development,
runtime: if let Some(runtime) = &swc_transforms_react_options.runtime {
Some(*runtime)
} else {
Some(Runtime::Automatic)
},
..swc_transforms_react_options
};

Expand Down
2 changes: 1 addition & 1 deletion examples/emotion/farm.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,5 @@ export default defineConfig({
// treeShaking: true,
// minify: true,
},
plugins: [['@farmfe/plugin-react', { "runtime": "automatic", "importSource": "@emotion/react" }]],
plugins: [['@farmfe/plugin-react', { importSource: '@emotion/react' }]],
});
2 changes: 1 addition & 1 deletion examples/react/alias.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export default defineConfig(() => {
}
},
plugins: [
['@farmfe/plugin-react', { runtime: 'automatic' }],
'@farmfe/plugin-react',
'@farmfe/plugin-sass',
],
}
Expand Down
2 changes: 1 addition & 1 deletion examples/react/farm.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export default defineConfig(() => {
}
},
plugins: [
['@farmfe/plugin-react', { runtime: 'automatic' }],
'@farmfe/plugin-react',
'@farmfe/plugin-sass'
]
};
Expand Down

0 comments on commit a9b5db7

Please sign in to comment.