Skip to content

Commit 485fced

Browse files
authored
fix(es/minifier): Fix top level option (#10227)
**Description:** Top-level compression should be enabled if the user specified, regardless of whether it's a module
1 parent 0f2c8d5 commit 485fced

File tree

3 files changed

+147
-108
lines changed

3 files changed

+147
-108
lines changed

.changeset/brave-games-fold.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
swc_core: patch
3+
swc: patch
4+
---
5+
6+
fix(es): Fix option bug

crates/swc/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -826,7 +826,7 @@ impl Compiler {
826826
)
827827
.context("failed to parse input file")?;
828828

829-
if program.is_module() {
829+
if opts.toplevel == Some(true) || program.is_module() {
830830
if let Some(opts) = &mut min_opts.compress {
831831
if opts.top_level.is_none() {
832832
opts.top_level = Some(TopLevelOptions { functions: true });

0 commit comments

Comments
 (0)