Skip to content

Commit

Permalink
fix(ecma/minifier): handle script in bundle mode
Browse files Browse the repository at this point in the history
  • Loading branch information
alexander-akait committed Nov 17, 2022
1 parent d0968c1 commit 1d9c952
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions crates/swc_ecma_minifier/src/metadata/mod.rs
Expand Up @@ -191,12 +191,23 @@ impl VisitMut for InfoMarker<'_> {

fn visit_mut_lit(&mut self, _: &mut Lit) {}

fn visit_mut_module(&mut self, m: &mut Module) {
m.visit_mut_children_with(self);
fn visit_mut_module(&mut self, n: &mut Module) {
n.visit_mut_children_with(self);

if self.state.is_bundle {
tracing::info!("Running minifier in the bundle mode");
n.span = n.span.apply_mark(self.marks.bundle_of_standalone);
} else {
tracing::info!("Running minifier in the normal mode");
}
}

fn visit_mut_script(&mut self, n: &mut Script) {
n.visit_mut_children_with(self);

if self.state.is_bundle {
tracing::info!("Running minifier in the bundle mode");
m.span = m.span.apply_mark(self.marks.bundle_of_standalone);
n.span = n.span.apply_mark(self.marks.bundle_of_standalone);
} else {
tracing::info!("Running minifier in the normal mode");
}
Expand Down

0 comments on commit 1d9c952

Please sign in to comment.