Skip to content

Commit

Permalink
refactor(ecma/minifier): code
Browse files Browse the repository at this point in the history
  • Loading branch information
alexander-akait committed Nov 17, 2022
1 parent 1d9c952 commit eeba640
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
8 changes: 8 additions & 0 deletions crates/swc_ecma_minifier/src/analyzer/mod.rs
Expand Up @@ -1150,6 +1150,14 @@ where
n.visit_children_with(&mut *self.with_ctx(ctx))
}

fn visit_script(&mut self, n: &Script) {
let ctx = Ctx {
skip_standalone: true,
..self.ctx
};
n.visit_children_with(&mut *self.with_ctx(ctx))
}

fn visit_named_export(&mut self, n: &NamedExport) {
if n.src.is_some() {
return;
Expand Down
4 changes: 2 additions & 2 deletions crates/swc_ecma_minifier/src/compress/mod.rs
Expand Up @@ -336,11 +336,11 @@ where
{
noop_visit_mut_type!();

fn visit_mut_module(&mut self, n: &mut Module) {
fn visit_mut_script(&mut self, n: &mut Script) {
self.optimize_unit_repeatedly(n);
}

fn visit_mut_script(&mut self, n: &mut Script) {
fn visit_mut_module(&mut self, n: &mut Module) {
self.optimize_unit_repeatedly(n);
}

Expand Down
4 changes: 2 additions & 2 deletions crates/swc_ecma_minifier/src/metadata/mod.rs
Expand Up @@ -191,7 +191,7 @@ impl VisitMut for InfoMarker<'_> {

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

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

if self.state.is_bundle {
Expand All @@ -202,7 +202,7 @@ impl VisitMut for InfoMarker<'_> {
}
}

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

if self.state.is_bundle {
Expand Down

0 comments on commit eeba640

Please sign in to comment.