Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(html/minifier): use the latest target for merging #6453

Merged
merged 3 commits into from
Nov 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions crates/swc_html_minifier/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1988,8 +1988,8 @@ impl Minifier<'_> {
let mut left_errors: Vec<_> = vec![];
let left_fm = cm.new_source_file(FileName::Anon, left);
let syntax = swc_ecma_parser::Syntax::default();
// TODO improve me using options
let target = swc_ecma_ast::EsVersion::default();
// Use the latest target for merging
let target = swc_ecma_ast::EsVersion::latest();

let mut left_program = if is_modules {
match swc_ecma_parser::parse_file_as_module(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"minifyJs": {
"parser": {
"comments": true,
"syntax": "ecmascript",
"target": "es2022"
},
"codegen": {
"asciiOnly": false
}
}
}
Original file line number Diff line number Diff line change
@@ -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>
Original file line number Diff line number Diff line change
@@ -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>
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"minifyJs": false
}
Original file line number Diff line number Diff line change
@@ -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>
Original file line number Diff line number Diff line change
@@ -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>
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"minifyJs": {
"codegen": {
"asciiOnly": true
}
}
}
Original file line number Diff line number Diff line change
@@ -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>
Original file line number Diff line number Diff line change
@@ -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>