Repository: swc-project/swc
File: crates/swc_ecma_minifier/src/compress/optimize/sequences.rs (Rust)

Code before:
            }

            Expr::Call(CallExpr {
                callee: Callee::Super(_),
                args: b_args,
                ..
            }) => {
                trace_op!("seq: Try args of super call");

                // For super() calls, we need to be careful with arguments
                // because they are evaluated before the super constructor is called.
                // Similar to normal function calls, we check if arguments are skippable.
                for arg in b_args {
                    trace_op!("seq: Try arg of super");
                    if self.merge_sequential_expr(a, &mut arg.expr)? {
                        return Ok(true);
                    }

                    if !self.is_skippable_for_seq(Some(a), &arg.expr) {
                        return Ok(false);
                    }
                }

                return Ok(false);
            }

            Expr::New(NewExpr {
                callee: b_callee,
                args: b_args,
                ..
            }) => {
                trace_op!("seq: Try callee of new");
                if self.merge_sequential_expr(a, b_callee)? {
                    return Ok(true);
                }

                if !self.is_skippable_for_seq(Some(a), b_callee) {
                    return Ok(false);
                }

                if let Some(b_args) = b_args {
                    for arg in b_args {
                        trace_op!("seq: Try arg of new exp");

                        if self.merge_sequential_expr(a, &mut arg.expr)? {
                            return Ok(true);
                        }

                        if !self.is_skippable_for_seq(Some(a), &arg.expr) {
                            return Ok(false);
                        }

Review comment (bug):
The code handles `Callee::Super` but doesn't handle `Callee::Import`. Dynamic import calls (`import()`) also need the same safety checks to prevent incorrect sequence merging. Without this, the same evaluation order issue that affected `super()` could occur with `import()` calls. Consider adding a similar match arm for `Callee::Import` with the same argument handling logic.
```suggestion

            Expr::Call(CallExpr {
                callee: Callee::Import(_),
                args: b_args,
                ..
            }) => {
                trace_op!("seq: Try args of import call");

                // For dynamic import() calls, arguments are evaluated before
                // the import is performed. We must preserve this behavior,
                // so we apply the same safety checks as for super() calls.
                for arg in b_args {
                    trace_op!("seq: Try arg of import");
                    if self.merge_sequential_expr(a, &mut arg.expr)? {
                        return Ok(true);
                    }

                    if !self.is_skippable_for_seq(Some(a), &arg.expr) {
                        return Ok(false);
                    }
                }

                return Ok(false);
            }
```

Code after:
            }

            Expr::Call(CallExpr {
                callee: Callee::Super(_) | Callee::Import(_),
                args: b_args,
                ..
            }) => {
                trace_op!("seq: Try args of super call");

                // For super() calls, we need to be careful with arguments
                // because they are evaluated before the super constructor is called.
                // Similar to normal function calls, we check if arguments are skippable.
                for arg in b_args {
                    trace_op!("seq: Try arg of super");
                    if self.merge_sequential_expr(a, &mut arg.expr)? {
                        return Ok(true);
                    }

                    if !self.is_skippable_for_seq(Some(a), &arg.expr) {
                        return Ok(false);
                    }
                }

                return Ok(false);
            }

            Expr::New(NewExpr {
                callee: b_callee,
                args: b_args,
                ..
            }) => {
                trace_op!("seq: Try callee of new");
                if self.merge_sequential_expr(a, b_callee)? {
                    return Ok(true);
                }

                if !self.is_skippable_for_seq(Some(a), b_callee) {
                    return Ok(false);
                }

                if let Some(b_args) = b_args {
                    for arg in b_args {
                        trace_op!("seq: Try arg of new exp");

                        if self.merge_sequential_expr(a, &mut arg.expr)? {
                            return Ok(true);
                        }

                        if !self.is_skippable_for_seq(Some(a), &arg.expr) {
                            return Ok(false);
                        }