Skip to content
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
12 changes: 10 additions & 2 deletions crates/oxc_minifier/src/peephole/remove_dead_code.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,10 @@ impl<'a, 'b> PeepholeOptimizations {
if i - 1 <= index {
return true;
}
// keep function declaration
if matches!(s.as_declaration(), Some(Declaration::FunctionDeclaration(_))) {
// Keep module syntax and function declaration
if s.is_module_declaration()
|| matches!(s.as_declaration(), Some(Declaration::FunctionDeclaration(_)))
{
return true;
}
false
Expand Down Expand Up @@ -812,4 +814,10 @@ mod test {
test("!1", "");
test("1", "");
}

#[test]
fn keep_module_syntax() {
test_same("throw foo; export let bar");
test_same("throw foo; export default bar");
}
}
Loading