feat(html/minifier): Use the latest EsVersion (#6453)

This commit is contained in:
Alexander Akait 2022-11-18 05:32:55 +03:00 committed by GitHub
parent e055d2c4f8
commit 7f6bf59a98
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 89 additions and 2 deletions

View File

@ -1988,8 +1988,8 @@ impl Minifier<'_> {
let mut left_errors: Vec<_> = vec![]; let mut left_errors: Vec<_> = vec![];
let left_fm = cm.new_source_file(FileName::Anon, left); let left_fm = cm.new_source_file(FileName::Anon, left);
let syntax = swc_ecma_parser::Syntax::default(); let syntax = swc_ecma_parser::Syntax::default();
// TODO improve me using options // Use the latest target for merging
let target = swc_ecma_ast::EsVersion::default(); let target = swc_ecma_ast::EsVersion::latest();
let mut left_program = if is_modules { let mut left_program = if is_modules {
match swc_ecma_parser::parse_file_as_module( match swc_ecma_parser::parse_file_as_module(

View File

@ -0,0 +1,12 @@
{
"minifyJs": {
"parser": {
"comments": true,
"syntax": "ecmascript",
"target": "es2022"
},
"codegen": {
"asciiOnly": false
}
}
}

View File

@ -0,0 +1,14 @@
<!doctype html>
<html lang="en">
<head>
<title>Document</title>
</head>
<body>
<script>var test1 = "😋";</script>
<div>test</div>
<script>var test2 = "😋";</script>
<script>var test3 = "😋";</script>
<div>number</div>
<script>var test4 = 123_456_789;</script>
</body>
</html>

View File

@ -0,0 +1,5 @@
<!doctype html><html lang=en><title>Document</title><body><script>var test1="😋"</script>
<div>test</div>
<script>var test2="😋",test3="😋"</script>
<div>number</div>
<script>var test4=123456789</script>

View File

@ -0,0 +1,3 @@
{
"minifyJs": false
}

View File

@ -0,0 +1,16 @@
<!doctype html>
<html lang="en">
<head>
<title>Document</title>
</head>
<body>
<script>var test1 = "😋";</script>
<div>test</div>
<script>var test2 = "😋";</script>
<script>var test3 = "😋";</script>
<div>number</div>
<script>var test4 = 123_456_789;</script>
<div>emoji</div>
<script>var test5="\uD83D\uDE0B";</script><script>var test6="\uD83D\uDE0B"</script>
</body>
</html>

View File

@ -0,0 +1,11 @@
<!doctype html><html lang=en><title>Document</title><body><script>var test1 = "😋";</script>
<div>test</div>
<script>var test2 = "😋";
var test3 = "😋";
</script>
<div>number</div>
<script>var test4 = 123_456_789;</script>
<div>emoji</div>
<script>var test5 = "\uD83D\uDE0B";
var test6 = "\uD83D\uDE0B";
</script>

View File

@ -0,0 +1,7 @@
{
"minifyJs": {
"codegen": {
"asciiOnly": true
}
}
}

View File

@ -0,0 +1,14 @@
<!doctype html>
<html lang="en">
<head>
<title>Document</title>
</head>
<body>
<script>var test1 = "😋";</script>
<div>test</div>
<script>var test2 = "😋";</script>
<script>var test3 = "😋";</script>
<div>number</div>
<script>var test4 = 123_456_789;</script>
</body>
</html>

View File

@ -0,0 +1,5 @@
<!doctype html><html lang=en><title>Document</title><body><script>var test1="\uD83D\uDE0B"</script>
<div>test</div>
<script>var test2="\uD83D\uDE0B",test3="\uD83D\uDE0B"</script>
<div>number</div>
<script>var test4=123456789</script>