Skip to content

Commit

Permalink
fix build
Browse files Browse the repository at this point in the history
  • Loading branch information
kdy1 committed Jan 23, 2025
1 parent efd0de0 commit d21530f
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 8 deletions.
32 changes: 30 additions & 2 deletions crates/swc_ecma_minifier/src/compress/optimize/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,36 @@ pub(super) fn optimizer<'a>(
unresolved_ctxt: SyntaxContext::empty().apply_mark(marks.unresolved_mark),
is_unresolved_ref_safe: false,
in_strict: options.module,
remaining_depth: 2,
},
..Ctx::default()
has_const_ann: false,
dont_use_prepend_nor_append: false,
in_bool_ctx: false,
in_asm: false,
is_callee: false,
var_kind: None,
in_try_block: false,
in_cond: false,
is_delete_arg: false,
is_update_arg: false,
is_lhs_of_assign: false,
is_exact_lhs_of_assign: false,
executed_multiple_time: false,
in_bang_arg: false,
in_var_decl_of_for_in_or_of_loop: false,
dont_use_negated_iife: false,
is_exported: false,
top_level: false,
in_fn_like: false,
in_block: false,
in_obj_of_non_computed_member: false,
in_tpl_expr: false,
is_this_aware_callee: false,
is_nested_if_return_merging: false,
dont_invoke_iife: false,
in_with_stmt: false,
in_param: false,
scope: SyntaxContext::default(),
};

Optimizer {
Expand All @@ -99,7 +127,7 @@ pub(super) fn optimizer<'a>(
/// Syntactic context.
///
/// This should not be modified directly. Use `.with_ctx()` instead.
#[derive(Debug, Default, Clone)]
#[derive(Debug, Clone)]
struct Ctx {
expr_ctx: ExprCtx,

Expand Down
6 changes: 2 additions & 4 deletions crates/swc_ecma_minifier/src/compress/pure/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ pub(crate) fn pure_optimizer<'a>(
unresolved_ctxt: SyntaxContext::empty().apply_mark(marks.unresolved_mark),
is_unresolved_ref_safe: false,
in_strict: options.module,
remaining_depth: 4,
},
ctx: Default::default(),
changed: Default::default(),
Expand All @@ -79,10 +80,7 @@ struct Pure<'a> {

impl Parallel for Pure<'_> {
fn create(&self) -> Self {
Self {
expr_ctx: self.expr_ctx.clone(),
..*self
}
Self { ..*self }
}

fn merge(&mut self, other: Self) {
Expand Down
5 changes: 3 additions & 2 deletions crates/swc_ecma_minifier/src/compress/util/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,12 @@ fn assert_negate_cost(s: &str, in_bool_ctx: bool, is_ret_val_ignored: bool, expe
unresolved_ctxt: SyntaxContext::empty().apply_mark(Mark::new()),
is_unresolved_ref_safe: false,
in_strict: false,
remaining_depth: 2,
};

let real = {
let mut real = e.clone();
negate(&expr_ctx, &mut real, in_bool_ctx, is_ret_val_ignored);
negate(expr_ctx, &mut real, in_bool_ctx, is_ret_val_ignored);
real.visit_mut_with(&mut fixer(None));
dump(&real, true)
};
Expand All @@ -69,7 +70,7 @@ fn assert_negate_cost(s: &str, in_bool_ctx: bool, is_ret_val_ignored: bool, expe
info!("Input: {}", input);
}

let actual = negate_cost(&expr_ctx, &e, in_bool_ctx, is_ret_val_ignored);
let actual = negate_cost(expr_ctx, &e, in_bool_ctx, is_ret_val_ignored);

assert_eq!(
actual, expected,
Expand Down
1 change: 1 addition & 0 deletions crates/swc_ecma_minifier/src/eval.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ impl Evaluator {
unresolved_ctxt: SyntaxContext::empty().apply_mark(marks.unresolved_mark),
is_unresolved_ref_safe: false,
in_strict: true,
remaining_depth: 3,
},

module,
Expand Down
1 change: 1 addition & 0 deletions crates/swc_ecma_minifier/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ pub fn optimize(
unresolved_ctxt: SyntaxContext::empty().apply_mark(marks.unresolved_mark),
is_unresolved_ref_safe: false,
in_strict: false,
remaining_depth: 6,
}));
debug_assert_valid(&n);
}
Expand Down

0 comments on commit d21530f

Please sign in to comment.