fix(es/minifier): Don't remove exports (#7856)

This commit is contained in:
Lewis Liu 2023-08-24 21:47:42 -07:00 committed by GitHub
parent 5ae2e810d8
commit ae8cd9430d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 18 additions and 0 deletions

View File

@ -318,6 +318,10 @@ impl From<&Function> for FnMetadata {
impl Optimizer<'_> { impl Optimizer<'_> {
fn may_remove_ident(&self, id: &Ident) -> bool { fn may_remove_ident(&self, id: &Ident) -> bool {
if self.ctx.is_exported {
return false;
}
if id.span.ctxt != self.marks.top_level_ctxt { if id.span.ctxt != self.marks.top_level_ctxt {
return true; return true;
} }

View File

@ -0,0 +1,4 @@
const a = () => "";
const b = {};
export const c = a;
b.c = c;

View File

@ -0,0 +1 @@
export const c = ()=>"";

View File

@ -0,0 +1,5 @@
export const a = 4;
export const b = 16;
export const c = 5;
export const d = () => a;

View File

@ -0,0 +1,4 @@
export const a = 4;
export const b = 16;
export const c = 5;
export const d = ()=>4;