mirror of
https://github.com/danbulant/oxc
synced 2026-05-19 04:08:41 +00:00
refactor(transformer): deserialize BabelOptions::compiler_assumptions (#7048)
This commit is contained in:
parent
f83a760d8a
commit
6d92f36ef2
2 changed files with 4 additions and 12 deletions
|
|
@ -5,10 +5,10 @@ mod presets;
|
|||
use std::path::{Path, PathBuf};
|
||||
|
||||
use serde::{de::DeserializeOwned, Deserialize};
|
||||
use serde_json::Value;
|
||||
|
||||
pub use env::{BabelEnvOptions, Targets};
|
||||
use crate::CompilerAssumptions;
|
||||
|
||||
pub use self::env::{BabelEnvOptions, Targets};
|
||||
use self::{plugins::BabelPlugins, presets::BabelPresets};
|
||||
|
||||
/// Babel options
|
||||
|
|
@ -33,7 +33,7 @@ pub struct BabelOptions {
|
|||
pub source_type: Option<String>,
|
||||
|
||||
#[serde(default)]
|
||||
pub assumptions: Value,
|
||||
pub assumptions: CompilerAssumptions,
|
||||
|
||||
// Test options
|
||||
pub throws: Option<String>,
|
||||
|
|
|
|||
|
|
@ -75,14 +75,6 @@ impl TryFrom<&BabelOptions> for TransformOptions {
|
|||
errors.extend(options.plugins.errors.iter().map(|err| Error::msg(err.clone())));
|
||||
errors.extend(options.presets.errors.iter().map(|err| Error::msg(err.clone())));
|
||||
|
||||
let assumptions = if options.assumptions.is_null() {
|
||||
CompilerAssumptions::default()
|
||||
} else {
|
||||
serde_json::from_value::<CompilerAssumptions>(options.assumptions.clone())
|
||||
.map_err(|err| errors.push(Error::msg(err)))
|
||||
.unwrap_or_default()
|
||||
};
|
||||
|
||||
let typescript = options
|
||||
.presets
|
||||
.typescript
|
||||
|
|
@ -131,7 +123,7 @@ impl TryFrom<&BabelOptions> for TransformOptions {
|
|||
|
||||
Ok(Self {
|
||||
cwd: options.cwd.clone().unwrap_or_default(),
|
||||
assumptions,
|
||||
assumptions: options.assumptions,
|
||||
typescript,
|
||||
jsx,
|
||||
env: env.unwrap_or_default(),
|
||||
|
|
|
|||
Loading…
Reference in a new issue