mirror of
https://github.com/danbulant/oxc
synced 2026-05-19 04:08:41 +00:00
fix(napi/transform): remove confusing jsx option (#6159)
This commit is contained in:
parent
ea908f742d
commit
f27d59f748
3 changed files with 45 additions and 60 deletions
8
napi/transform/index.d.ts
vendored
8
napi/transform/index.d.ts
vendored
|
|
@ -187,18 +187,12 @@ export interface TransformOptions {
|
|||
* options.
|
||||
*/
|
||||
cwd?: string
|
||||
/**
|
||||
* Force jsx parsing,
|
||||
*
|
||||
* @default false
|
||||
*/
|
||||
jsx?: boolean
|
||||
/** Configure how TypeScript is transformed. */
|
||||
typescript?: TypeScriptBindingOptions
|
||||
/** Configure how TSX and JSX are transformed. */
|
||||
react?: ReactBindingOptions
|
||||
/** Enable ES2015 transformations. */
|
||||
es2015?: Es2015BindingOptions
|
||||
es2015?: ES2015BindingOptions
|
||||
/**
|
||||
* Enable source map generation.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -11,6 +11,50 @@ use oxc_transformer::{
|
|||
|
||||
use crate::IsolatedDeclarationsOptions;
|
||||
|
||||
/// Options for transforming a JavaScript or TypeScript file.
|
||||
///
|
||||
/// @see {@link transform}
|
||||
#[napi(object)]
|
||||
#[derive(Default)]
|
||||
pub struct TransformOptions {
|
||||
#[napi(ts_type = "'script' | 'module' | 'unambiguous' | undefined")]
|
||||
pub source_type: Option<String>,
|
||||
|
||||
/// The current working directory. Used to resolve relative paths in other
|
||||
/// options.
|
||||
pub cwd: Option<String>,
|
||||
|
||||
/// Configure how TypeScript is transformed.
|
||||
pub typescript: Option<TypeScriptBindingOptions>,
|
||||
|
||||
/// Configure how TSX and JSX are transformed.
|
||||
pub react: Option<ReactBindingOptions>,
|
||||
|
||||
/// Enable ES2015 transformations.
|
||||
pub es2015: Option<ES2015BindingOptions>,
|
||||
|
||||
/// Enable source map generation.
|
||||
///
|
||||
/// When `true`, the `sourceMap` field of transform result objects will be populated.
|
||||
///
|
||||
/// @default false
|
||||
///
|
||||
/// @see {@link SourceMap}
|
||||
pub sourcemap: Option<bool>,
|
||||
}
|
||||
|
||||
impl From<TransformOptions> for oxc_transformer::TransformOptions {
|
||||
fn from(options: TransformOptions) -> Self {
|
||||
Self {
|
||||
cwd: options.cwd.map(PathBuf::from).unwrap_or_default(),
|
||||
typescript: options.typescript.map(Into::into).unwrap_or_default(),
|
||||
react: options.react.map(Into::into).unwrap_or_default(),
|
||||
es2015: options.es2015.map(Into::into).unwrap_or_default(),
|
||||
..Self::default()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[napi(object)]
|
||||
#[derive(Default)]
|
||||
pub struct TypeScriptBindingOptions {
|
||||
|
|
@ -234,52 +278,3 @@ impl From<ES2015BindingOptions> for ES2015Options {
|
|||
ES2015Options { arrow_function: options.arrow_function.map(Into::into) }
|
||||
}
|
||||
}
|
||||
|
||||
/// Options for transforming a JavaScript or TypeScript file.
|
||||
///
|
||||
/// @see {@link transform}
|
||||
#[napi(object)]
|
||||
#[derive(Default)]
|
||||
pub struct TransformOptions {
|
||||
#[napi(ts_type = "'script' | 'module' | 'unambiguous' | undefined")]
|
||||
pub source_type: Option<String>,
|
||||
|
||||
/// The current working directory. Used to resolve relative paths in other
|
||||
/// options.
|
||||
pub cwd: Option<String>,
|
||||
|
||||
/// Force jsx parsing,
|
||||
///
|
||||
/// @default false
|
||||
pub jsx: Option<bool>,
|
||||
|
||||
/// Configure how TypeScript is transformed.
|
||||
pub typescript: Option<TypeScriptBindingOptions>,
|
||||
|
||||
/// Configure how TSX and JSX are transformed.
|
||||
pub react: Option<ReactBindingOptions>,
|
||||
|
||||
/// Enable ES2015 transformations.
|
||||
pub es2015: Option<ES2015BindingOptions>,
|
||||
|
||||
/// Enable source map generation.
|
||||
///
|
||||
/// When `true`, the `sourceMap` field of transform result objects will be populated.
|
||||
///
|
||||
/// @default false
|
||||
///
|
||||
/// @see {@link SourceMap}
|
||||
pub sourcemap: Option<bool>,
|
||||
}
|
||||
|
||||
impl From<TransformOptions> for oxc_transformer::TransformOptions {
|
||||
fn from(options: TransformOptions) -> Self {
|
||||
Self {
|
||||
cwd: options.cwd.map(PathBuf::from).unwrap_or_default(),
|
||||
typescript: options.typescript.map(Into::into).unwrap_or_default(),
|
||||
react: options.react.map(Into::into).unwrap_or_default(),
|
||||
es2015: options.es2015.map(Into::into).unwrap_or_default(),
|
||||
..Self::default()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -70,10 +70,6 @@ pub fn transform(
|
|||
Some("module") => source_type = source_type.with_module(true),
|
||||
_ => {}
|
||||
}
|
||||
// Force `jsx`
|
||||
if let Some(jsx) = options.as_ref().and_then(|options| options.jsx.as_ref()) {
|
||||
source_type = source_type.with_jsx(*jsx);
|
||||
}
|
||||
source_type
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue