mirror of
https://github.com/danbulant/oxc
synced 2026-05-19 12:19:15 +00:00
fix(minifier): keep esm in dce (#8677)
fixes https://github.com/rolldown/rolldown/issues/3402
This commit is contained in:
parent
ce2b9da5c7
commit
883d25b27d
1 changed files with 10 additions and 2 deletions
|
|
@ -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
|
||||
|
|
@ -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…
Reference in a new issue