Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(transformer): deserialize BabelOptions::compiler_assumptions #7048

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions crates/oxc_transformer/src/options/babel/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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>,
Expand Down
10 changes: 1 addition & 9 deletions crates/oxc_transformer/src/options/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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(),
Expand Down
Loading