mirror of
https://github.com/danbulant/oxc
synced 2026-05-19 04:08:41 +00:00
feat(napi/transform): make react refresh option take a boolean (#6146)
This commit is contained in:
parent
bfd19882b0
commit
f50fdcd0f9
2 changed files with 18 additions and 5 deletions
10
napi/transform/index.d.ts
vendored
10
napi/transform/index.d.ts
vendored
|
|
@ -124,8 +124,14 @@ export interface ReactBindingOptions {
|
|||
* @default false
|
||||
*/
|
||||
useSpread?: boolean
|
||||
/** Enable react fast refresh transform */
|
||||
refresh?: ReactRefreshBindingOptions
|
||||
/**
|
||||
* Enable React Fast Refresh .
|
||||
*
|
||||
* Conforms to the implementation in {@link https://github.com/facebook/react/tree/main/packages/react-refresh}
|
||||
*
|
||||
* @default false
|
||||
*/
|
||||
refresh?: boolean | ReactRefreshBindingOptions
|
||||
}
|
||||
|
||||
export interface ReactRefreshBindingOptions {
|
||||
|
|
|
|||
|
|
@ -147,8 +147,12 @@ pub struct ReactBindingOptions {
|
|||
/// @default false
|
||||
pub use_spread: Option<bool>,
|
||||
|
||||
/// Enable react fast refresh transform
|
||||
pub refresh: Option<ReactRefreshBindingOptions>,
|
||||
/// Enable React Fast Refresh .
|
||||
///
|
||||
/// Conforms to the implementation in {@link https://github.com/facebook/react/tree/main/packages/react-refresh}
|
||||
///
|
||||
/// @default false
|
||||
pub refresh: Option<Either<bool, ReactRefreshBindingOptions>>,
|
||||
}
|
||||
|
||||
impl From<ReactBindingOptions> for ReactOptions {
|
||||
|
|
@ -167,7 +171,10 @@ impl From<ReactBindingOptions> for ReactOptions {
|
|||
pragma_frag: options.pragma_frag,
|
||||
use_built_ins: options.use_built_ins,
|
||||
use_spread: options.use_spread,
|
||||
refresh: options.refresh.map(Into::into),
|
||||
refresh: options.refresh.and_then(|value| match value {
|
||||
Either::A(b) => b.then(ReactRefreshOptions::default),
|
||||
Either::B(options) => Some(ReactRefreshOptions::from(options)),
|
||||
}),
|
||||
..Default::default()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue