Unverified Commit c3bb0f18 authored by Donny/강동윤's avatar Donny/강동윤 Committed by GitHub

fix(turbopack): Apply `hygiene` if mangling is disabled (#77815)

### What?

Apply the normal variable renamer when we are not going to apply minfiying var renamer.

### Why?

Var renamer should be applied at least once.

### How?

Closes PACK-4245
parent fc5bea4c
......@@ -16,7 +16,10 @@ use swc_core::{
},
minifier::option::{CompressOptions, ExtraOptions, MangleOptions, MinifyOptions},
parser::{lexer::Lexer, Parser, StringInput, Syntax},
transforms::base::fixer::paren_remover,
transforms::base::{
fixer::paren_remover,
hygiene::{self, hygiene_with_config},
},
},
};
use tracing::{instrument, Level};
......@@ -99,6 +102,13 @@ pub fn minify(path: &FileSystemPath, code: &Code, source_maps: bool, mangle: boo
},
);
if !mangle {
program.mutate(hygiene_with_config(hygiene::Config {
top_level_mark,
..Default::default()
}));
}
Ok(program.apply(ecma::transforms::base::fixer::fixer(Some(
&comments as &dyn Comments,
))))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment