swc/crates/swc_ecma_minifier/tests/single-pass/1/input.js
Donny/강동윤 68e9017376
fix(es/minifier): Improve minifier (#3350)
swc_ecma_transforms_optimization:
 - `expr_simplifier`: Track more changes.

swc_ecma_minifier:
 - Analyze after applying the pure optimizer.
 - Preserve access to a variable not in scope.
 - `compress`: Remove string literal if it was not a directive.
 - `pure/collapse_vars`: Merge vars declared in the first statement into one with initializers if `collapse_vars` and `join_vars` are enabled.
 - `unused`: Use `usage_count` instead of `ref_count`.
 - `unused`: Fix dropping rule for member expressions.
 - `unused`: Fix dropping rule for declarations.
 - `hoist_props`: Preserve exported items.
2022-01-27 15:36:22 +09:00

57 lines
2.2 KiB
JavaScript

var condString;
var exprAny1;
var exprBoolean1;
var exprNumber1;
var exprString1;
var exprIsObject1;
var exprAny2;
var exprBoolean2;
var exprNumber2;
var exprString2;
var exprIsObject2;
condString ? exprAny1 : exprAny2;
condString ? exprBoolean1 : exprBoolean2;
condString ? exprNumber1 : exprNumber2;
condString ? exprString1 : exprString2;
condString ? exprIsObject1 : exprIsObject2;
condString ? exprString1 : exprBoolean1;
"" ? exprAny1 : exprAny2;
"string" ? exprBoolean1 : exprBoolean2;
"c" ? exprNumber1 : exprNumber2;
"string" ? exprString1 : exprString2;
" " ? exprIsObject1 : exprIsObject2;
"hello " ? exprString1 : exprBoolean1;
function foo() {
return "string";
}
var array = [
"1",
"2",
"3"
];
typeof condString ? exprAny1 : exprAny2;
condString.toUpperCase ? exprBoolean1 : exprBoolean2;
condString + "string" ? exprNumber1 : exprNumber2;
foo() ? exprString1 : exprString2;
array[1] ? exprIsObject1 : exprIsObject2;
foo() ? exprString1 : exprBoolean1;
var resultIsAny1 = condString ? exprAny1 : exprAny2;
var resultIsBoolean1 = condString ? exprBoolean1 : exprBoolean2;
var resultIsNumber1 = condString ? exprNumber1 : exprNumber2;
var resultIsString1 = condString ? exprString1 : exprString2;
var resultIsObject1 = condString ? exprIsObject1 : exprIsObject2;
var resultIsStringOrBoolean1 = condString ? exprString1 : exprBoolean1;
var resultIsAny2 = "" ? exprAny1 : exprAny2;
var resultIsBoolean2 = "string" ? exprBoolean1 : exprBoolean2;
var resultIsNumber2 = "c" ? exprNumber1 : exprNumber2;
var resultIsString2 = "string" ? exprString1 : exprString2;
var resultIsObject2 = " " ? exprIsObject1 : exprIsObject2;
var resultIsStringOrBoolean2 = "hello" ? exprString1 : exprBoolean1;
var resultIsAny3 = typeof condString ? exprAny1 : exprAny2;
var resultIsBoolean3 = condString.toUpperCase ? exprBoolean1 : exprBoolean2;
var resultIsNumber3 = condString + "string" ? exprNumber1 : exprNumber2;
var resultIsString3 = foo() ? exprString1 : exprString2;
var resultIsObject3 = array[1] ? exprIsObject1 : exprIsObject2;
var resultIsStringOrBoolean3 = typeof condString ? exprString1 : exprBoolean1;
var resultIsStringOrBoolean4 = condString.toUpperCase ? exprString1 : exprBoolean1;