Skip to content

Commit

Permalink
fix: optional plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
magic-akari committed Aug 23, 2024
1 parent d926585 commit 1eae327
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions crates/oxc_transformer/src/es2018/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,15 @@ pub struct ES2018<'a> {
options: ES2018Options,

// Plugins
object_rest_spread: ObjectRestSpread<'a>,
object_rest_spread: Option<ObjectRestSpread<'a>>,
}

impl<'a> ES2018<'a> {
pub fn new(options: ES2018Options, ctx: Ctx<'a>) -> Self {
Self {
object_rest_spread: ObjectRestSpread::new(
options.object_rest_spread.unwrap_or_default(),
Rc::clone(&ctx),
),
object_rest_spread: options
.object_rest_spread
.map(|options| ObjectRestSpread::new(options, Rc::clone(&ctx))),
ctx,
options,
}
Expand All @@ -35,6 +34,8 @@ impl<'a> ES2018<'a> {

impl<'a> Traverse<'a> for ES2018<'a> {
fn enter_expression(&mut self, expr: &mut Expression<'a>, ctx: &mut TraverseCtx<'a>) {
self.object_rest_spread.enter_expression(expr, ctx);
if let Some(object_rest_spread) = &mut self.object_rest_spread {
object_rest_spread.enter_expression(expr, ctx);
}
}
}

0 comments on commit 1eae327

Please sign in to comment.