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/object-reset-spread): make plugin initialization unconditional #5319

Merged
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
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,15 +17,16 @@ pub struct ES2018<'a> {
options: ES2018Options,

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

impl<'a> ES2018<'a> {
pub fn new(options: ES2018Options, ctx: Ctx<'a>) -> Self {
Self {
object_rest_spread: options
.object_rest_spread
.map(|options| ObjectRestSpread::new(options, Rc::clone(&ctx))),
object_rest_spread: ObjectRestSpread::new(
options.object_rest_spread.unwrap_or_default(),
Rc::clone(&ctx),
),
ctx,
options,
}
Expand All @@ -34,8 +35,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>) {
if let Some(object_rest_spread) = &mut self.object_rest_spread {
object_rest_spread.enter_expression(expr, ctx);
if self.options.object_rest_spread.is_some() {
self.object_rest_spread.enter_expression(expr, ctx);
}
}
}