diff --git a/crates/swc/tests/fixture/hygiene/issue-3213/1/input/.swcrc b/crates/swc/tests/fixture/hygiene/issue-3213/1/input/.swcrc new file mode 100644 index 00000000000..a7f299ab340 --- /dev/null +++ b/crates/swc/tests/fixture/hygiene/issue-3213/1/input/.swcrc @@ -0,0 +1,19 @@ +{ + "jsc": { + "parser": { + "syntax": "ecmascript", + "jsx": false + }, + "target": "es5", + "loose": true, + "minify": { + "compress": false, + "mangle": false + }, + "keepClassNames": true + }, + "module": { + "type": "es6" + }, + "minify": false +} \ No newline at end of file diff --git a/crates/swc/tests/fixture/hygiene/issue-3213/1/input/index.js b/crates/swc/tests/fixture/hygiene/issue-3213/1/input/index.js new file mode 100644 index 00000000000..a1f5387dc31 --- /dev/null +++ b/crates/swc/tests/fixture/hygiene/issue-3213/1/input/index.js @@ -0,0 +1,11 @@ +function f() { + var value$2 = 'original string'; + if (true) { + var value$21 = 'new string' + console.log(value$2) + } + [].map(function x(_) { + var value$2; // this causes the previous value$2 to become value$21 + return value$2 + }) +} \ No newline at end of file diff --git a/crates/swc/tests/fixture/hygiene/issue-3213/1/output/index.js b/crates/swc/tests/fixture/hygiene/issue-3213/1/output/index.js new file mode 100644 index 00000000000..3ceb4e1b088 --- /dev/null +++ b/crates/swc/tests/fixture/hygiene/issue-3213/1/output/index.js @@ -0,0 +1,11 @@ +function f() { + var value$22 = 'original string'; + if (true) { + var value$21 = 'new string'; + console.log(value$22); + } + [].map(function x(_) { + var value$2; + return value$2; + }); +} diff --git a/crates/swc/tests/fixture/hygiene/issue-3823/1/input/index.js b/crates/swc/tests/fixture/hygiene/issue-3823/1/input/index.js new file mode 100644 index 00000000000..5258de578d6 --- /dev/null +++ b/crates/swc/tests/fixture/hygiene/issue-3823/1/input/index.js @@ -0,0 +1,20 @@ +'use strict'; + +function print() { + var value$4 = 2; + var value$41 = value$4 + 100; + var c = 1; + if (true) { + var value$42 = "bbb"; + if (value$42 === "bbb") c = 3; + } + + [0, 1].map(function (value) { + var value$4 = 2; + var x = value ? value$4 : ""; + return x; + }); + return { aaa: value$4, bbb: c }; +} + +console.log(print()); \ No newline at end of file diff --git a/crates/swc/tests/fixture/hygiene/issue-3823/1/output/index.js b/crates/swc/tests/fixture/hygiene/issue-3823/1/output/index.js new file mode 100644 index 00000000000..b45392414d4 --- /dev/null +++ b/crates/swc/tests/fixture/hygiene/issue-3823/1/output/index.js @@ -0,0 +1,23 @@ +'use strict'; +function print() { + var value$43 = 2; + var value$41 = value$43 + 100; + var c = 1; + if (true) { + var value$42 = "bbb"; + if (value$42 === "bbb") c = 3; + } + [ + 0, + 1 + ].map(function(value) { + var value$4 = 2; + var x = value ? value$4 : ""; + return x; + }); + return { + aaa: value$43, + bbb: c + }; +} +console.log(print()); diff --git a/crates/swc/tests/tsc-references/asyncAwaitIsolatedModules_es2017_es2015.1.normal.js b/crates/swc/tests/tsc-references/asyncAwaitIsolatedModules_es2017_es2015.1.normal.js index e1dee4be7b4..58a3be782aa 100644 --- a/crates/swc/tests/tsc-references/asyncAwaitIsolatedModules_es2017_es2015.1.normal.js +++ b/crates/swc/tests/tsc-references/asyncAwaitIsolatedModules_es2017_es2015.1.normal.js @@ -149,14 +149,14 @@ class C { } var M; (function(M1) { - function f11() { + function f14() { return _f11.apply(this, arguments); } function _f11() { _f11 = _asyncToGenerator(function*() {}); return _f11.apply(this, arguments); } - M1.f1 = f11; + M1.f1 = f14; })(M || (M = {})); // @target: es2017 // @isolatedModules: true diff --git a/crates/swc/tests/tsc-references/asyncAwaitIsolatedModules_es2017_es5.1.normal.js b/crates/swc/tests/tsc-references/asyncAwaitIsolatedModules_es2017_es5.1.normal.js index 7576053b612..024668b3d18 100644 --- a/crates/swc/tests/tsc-references/asyncAwaitIsolatedModules_es2017_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/asyncAwaitIsolatedModules_es2017_es5.1.normal.js @@ -371,7 +371,7 @@ var C = /*#__PURE__*/ function() { }(); var M; (function(M1) { - function f11() { + function f14() { return _f11.apply(this, arguments); } function _f11() { @@ -386,7 +386,7 @@ var M; })); return _f11.apply(this, arguments); } - M1.f1 = f11; + M1.f1 = f14; })(M || (M = {})); // @target: es2017 // @isolatedModules: true diff --git a/crates/swc/tests/tsc-references/asyncAwaitIsolatedModules_es5_es2015.1.normal.js b/crates/swc/tests/tsc-references/asyncAwaitIsolatedModules_es5_es2015.1.normal.js index 1bd5f2e77cd..a2daba1f179 100644 --- a/crates/swc/tests/tsc-references/asyncAwaitIsolatedModules_es5_es2015.1.normal.js +++ b/crates/swc/tests/tsc-references/asyncAwaitIsolatedModules_es5_es2015.1.normal.js @@ -149,14 +149,14 @@ class C { } var M; (function(M1) { - function f11() { + function f14() { return _f11.apply(this, arguments); } function _f11() { _f11 = _asyncToGenerator(function*() {}); return _f11.apply(this, arguments); } - M1.f1 = f11; + M1.f1 = f14; })(M || (M = {})); // @target: ES5 // @lib: es5,es2015.promise diff --git a/crates/swc/tests/tsc-references/asyncAwaitIsolatedModules_es5_es5.1.normal.js b/crates/swc/tests/tsc-references/asyncAwaitIsolatedModules_es5_es5.1.normal.js index 993ea05150f..06ee23e7248 100644 --- a/crates/swc/tests/tsc-references/asyncAwaitIsolatedModules_es5_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/asyncAwaitIsolatedModules_es5_es5.1.normal.js @@ -371,7 +371,7 @@ var C = /*#__PURE__*/ function() { }(); var M; (function(M1) { - function f11() { + function f14() { return _f11.apply(this, arguments); } function _f11() { @@ -386,7 +386,7 @@ var M; })); return _f11.apply(this, arguments); } - M1.f1 = f11; + M1.f1 = f14; })(M || (M = {})); // @target: ES5 // @lib: es5,es2015.promise diff --git a/crates/swc/tests/tsc-references/asyncAwaitIsolatedModules_es6_es2015.1.normal.js b/crates/swc/tests/tsc-references/asyncAwaitIsolatedModules_es6_es2015.1.normal.js index 8ee2e373d52..381b2785f18 100644 --- a/crates/swc/tests/tsc-references/asyncAwaitIsolatedModules_es6_es2015.1.normal.js +++ b/crates/swc/tests/tsc-references/asyncAwaitIsolatedModules_es6_es2015.1.normal.js @@ -149,14 +149,14 @@ class C { } var M; (function(M1) { - function f11() { + function f14() { return _f11.apply(this, arguments); } function _f11() { _f11 = _asyncToGenerator(function*() {}); return _f11.apply(this, arguments); } - M1.f1 = f11; + M1.f1 = f14; })(M || (M = {})); // @target: ES6 // @isolatedModules: true diff --git a/crates/swc/tests/tsc-references/asyncAwaitIsolatedModules_es6_es5.1.normal.js b/crates/swc/tests/tsc-references/asyncAwaitIsolatedModules_es6_es5.1.normal.js index 8b64ecd6cd5..867c5d6948c 100644 --- a/crates/swc/tests/tsc-references/asyncAwaitIsolatedModules_es6_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/asyncAwaitIsolatedModules_es6_es5.1.normal.js @@ -371,7 +371,7 @@ var C = /*#__PURE__*/ function() { }(); var M; (function(M1) { - function f11() { + function f14() { return _f11.apply(this, arguments); } function _f11() { @@ -386,7 +386,7 @@ var M; })); return _f11.apply(this, arguments); } - M1.f1 = f11; + M1.f1 = f14; })(M || (M = {})); // @target: ES6 // @isolatedModules: true diff --git a/crates/swc/tests/tsc-references/asyncAwait_es2017_es2015.1.normal.js b/crates/swc/tests/tsc-references/asyncAwait_es2017_es2015.1.normal.js index deab93ff5da..cdaf001d5c3 100644 --- a/crates/swc/tests/tsc-references/asyncAwait_es2017_es2015.1.normal.js +++ b/crates/swc/tests/tsc-references/asyncAwait_es2017_es2015.1.normal.js @@ -149,14 +149,14 @@ class C { } var M; (function(M1) { - function f11() { + function f15() { return _f11.apply(this, arguments); } function _f11() { _f11 = _asyncToGenerator(function*() {}); return _f11.apply(this, arguments); } - M1.f1 = f11; + M1.f1 = f15; })(M || (M = {})); function f14() { return _f14.apply(this, arguments); diff --git a/crates/swc/tests/tsc-references/asyncAwait_es2017_es5.1.normal.js b/crates/swc/tests/tsc-references/asyncAwait_es2017_es5.1.normal.js index e0c2aaa58c6..8cc2de13951 100644 --- a/crates/swc/tests/tsc-references/asyncAwait_es2017_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/asyncAwait_es2017_es5.1.normal.js @@ -371,7 +371,7 @@ var C = /*#__PURE__*/ function() { }(); var M; (function(M1) { - function f11() { + function f15() { return _f11.apply(this, arguments); } function _f11() { @@ -386,7 +386,7 @@ var M; })); return _f11.apply(this, arguments); } - M1.f1 = f11; + M1.f1 = f15; })(M || (M = {})); function f14() { return _f14.apply(this, arguments); diff --git a/crates/swc/tests/tsc-references/asyncAwait_es5_es2015.1.normal.js b/crates/swc/tests/tsc-references/asyncAwait_es5_es2015.1.normal.js index deab93ff5da..cdaf001d5c3 100644 --- a/crates/swc/tests/tsc-references/asyncAwait_es5_es2015.1.normal.js +++ b/crates/swc/tests/tsc-references/asyncAwait_es5_es2015.1.normal.js @@ -149,14 +149,14 @@ class C { } var M; (function(M1) { - function f11() { + function f15() { return _f11.apply(this, arguments); } function _f11() { _f11 = _asyncToGenerator(function*() {}); return _f11.apply(this, arguments); } - M1.f1 = f11; + M1.f1 = f15; })(M || (M = {})); function f14() { return _f14.apply(this, arguments); diff --git a/crates/swc/tests/tsc-references/asyncAwait_es5_es5.1.normal.js b/crates/swc/tests/tsc-references/asyncAwait_es5_es5.1.normal.js index e0c2aaa58c6..8cc2de13951 100644 --- a/crates/swc/tests/tsc-references/asyncAwait_es5_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/asyncAwait_es5_es5.1.normal.js @@ -371,7 +371,7 @@ var C = /*#__PURE__*/ function() { }(); var M; (function(M1) { - function f11() { + function f15() { return _f11.apply(this, arguments); } function _f11() { @@ -386,7 +386,7 @@ var M; })); return _f11.apply(this, arguments); } - M1.f1 = f11; + M1.f1 = f15; })(M || (M = {})); function f14() { return _f14.apply(this, arguments); diff --git a/crates/swc/tests/tsc-references/asyncAwait_es6_es2015.1.normal.js b/crates/swc/tests/tsc-references/asyncAwait_es6_es2015.1.normal.js index deab93ff5da..cdaf001d5c3 100644 --- a/crates/swc/tests/tsc-references/asyncAwait_es6_es2015.1.normal.js +++ b/crates/swc/tests/tsc-references/asyncAwait_es6_es2015.1.normal.js @@ -149,14 +149,14 @@ class C { } var M; (function(M1) { - function f11() { + function f15() { return _f11.apply(this, arguments); } function _f11() { _f11 = _asyncToGenerator(function*() {}); return _f11.apply(this, arguments); } - M1.f1 = f11; + M1.f1 = f15; })(M || (M = {})); function f14() { return _f14.apply(this, arguments); diff --git a/crates/swc/tests/tsc-references/asyncAwait_es6_es5.1.normal.js b/crates/swc/tests/tsc-references/asyncAwait_es6_es5.1.normal.js index e0c2aaa58c6..8cc2de13951 100644 --- a/crates/swc/tests/tsc-references/asyncAwait_es6_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/asyncAwait_es6_es5.1.normal.js @@ -371,7 +371,7 @@ var C = /*#__PURE__*/ function() { }(); var M; (function(M1) { - function f11() { + function f15() { return _f11.apply(this, arguments); } function _f11() { @@ -386,7 +386,7 @@ var M; })); return _f11.apply(this, arguments); } - M1.f1 = f11; + M1.f1 = f15; })(M || (M = {})); function f14() { return _f14.apply(this, arguments); diff --git a/crates/swc/tests/tsc-references/literalTypeWidening_es2015.1.normal.js b/crates/swc/tests/tsc-references/literalTypeWidening_es2015.1.normal.js index 5af1c67dfdf..4e6c1833588 100644 --- a/crates/swc/tests/tsc-references/literalTypeWidening_es2015.1.normal.js +++ b/crates/swc/tests/tsc-references/literalTypeWidening_es2015.1.normal.js @@ -126,8 +126,8 @@ function isSuccess(result1) { function isFailure(result2) { return result2 === FAILURE; } -function increment(x1) { - return x1 + 1; +function increment(x4) { + return x4 + 1; } let result = doWork(); if (isSuccess(result)) { diff --git a/crates/swc/tests/tsc-references/literalTypeWidening_es5.1.normal.js b/crates/swc/tests/tsc-references/literalTypeWidening_es5.1.normal.js index 299026c76e6..880c8731091 100644 --- a/crates/swc/tests/tsc-references/literalTypeWidening_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/literalTypeWidening_es5.1.normal.js @@ -126,8 +126,8 @@ function isSuccess(result1) { function isFailure(result2) { return result2 === FAILURE; } -function increment(x1) { - return x1 + 1; +function increment(x4) { + return x4 + 1; } var result = doWork(); if (isSuccess(result)) { diff --git a/crates/swc/tests/tsc-references/variadicTuples1_es2015.1.normal.js b/crates/swc/tests/tsc-references/variadicTuples1_es2015.1.normal.js index 91e088fe008..adb4ae0cf8f 100644 --- a/crates/swc/tests/tsc-references/variadicTuples1_es2015.1.normal.js +++ b/crates/swc/tests/tsc-references/variadicTuples1_es2015.1.normal.js @@ -189,7 +189,7 @@ function f15(k0, k1, k2, k3) { } // Inference to [...T, ...U] with implied arity for T function curry(f, ...a) { - return (...b1)=>f(...a, ...b1) + return (...b2)=>f(...a, ...b2) ; } const fn1 = (a, b, c, d)=>0 diff --git a/crates/swc/tests/tsc-references/variadicTuples1_es5.1.normal.js b/crates/swc/tests/tsc-references/variadicTuples1_es5.1.normal.js index bdda56b87f1..a1f2bfe5872 100644 --- a/crates/swc/tests/tsc-references/variadicTuples1_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/variadicTuples1_es5.1.normal.js @@ -253,10 +253,10 @@ function curry(f) { a[_key1 - 1] = arguments[_key1]; } return function() { - for(var _len = arguments.length, b1 = new Array(_len), _key = 0; _key < _len; _key++){ - b1[_key] = arguments[_key]; + for(var _len = arguments.length, b2 = new Array(_len), _key = 0; _key < _len; _key++){ + b2[_key] = arguments[_key]; } - return f.apply(void 0, _toConsumableArray(a).concat(_toConsumableArray(b1))); + return f.apply(void 0, _toConsumableArray(a).concat(_toConsumableArray(b2))); }; } var fn1 = function(a, b, c, d) { diff --git a/crates/swc_ecma_minifier/tests/compress/fixture/issues/2257/full/output.js b/crates/swc_ecma_minifier/tests/compress/fixture/issues/2257/full/output.js index 580304bfd2b..66d2155e347 100644 --- a/crates/swc_ecma_minifier/tests/compress/fixture/issues/2257/full/output.js +++ b/crates/swc_ecma_minifier/tests/compress/fixture/issues/2257/full/output.js @@ -10828,7 +10828,7 @@ } function qa(a2, b2, c1, d2) { var a1, e = D.hasOwnProperty(b2) ? D[b2] : null; - (null !== e ? 0 === e.type : !d2 && 2 < b2.length && ("o" === b2[0] || "O" === b2[0]) && ("n" === b2[1] || "N" === b2[1])) || ((function(a3, b3, c2, d3) { + (null !== e ? 0 === e.type : !d2 && 2 < b2.length && ("o" === b2[0] || "O" === b2[0]) && ("n" === b2[1] || "N" === b2[1])) || ((function(a3, b3, c3, d3) { if (null == b3 || (function(a, b, c, d) { if (null !== c && 0 === c.type) return !1; switch(typeof b){ @@ -10842,9 +10842,9 @@ default: return !1; } - })(a3, b3, c2, d3)) return !0; + })(a3, b3, c3, d3)) return !0; if (d3) return !1; - if (null !== c2) switch(c2.type){ + if (null !== c3) switch(c3.type){ case 3: return !b3; case 4: @@ -11716,17 +11716,17 @@ function id(a, b, c, d) { ed(dd, hd.bind(null, a, b, c, d)); } - function hd(a10, b7, c3, d4) { + function hd(a10, b7, c4, d4) { if (fd) { var e2; - if ((e2 = 0 == (4 & b7)) && 0 < jc.length && -1 < qc.indexOf(a10)) a10 = rc(null, a10, b7, c3, d4), jc.push(a10); + if ((e2 = 0 == (4 & b7)) && 0 < jc.length && -1 < qc.indexOf(a10)) a10 = rc(null, a10, b7, c4, d4), jc.push(a10); else { - var f1 = yc(a10, b7, c3, d4); + var f1 = yc(a10, b7, c4, d4); if (null === f1) e2 && sc(a10, d4); else { if (e2) { if (-1 < qc.indexOf(a10)) { - a10 = rc(f1, a10, b7, c3, d4), jc.push(a10); + a10 = rc(f1, a10, b7, c4, d4), jc.push(a10); return; } if ((function(a, b, c, d, e) { @@ -11744,10 +11744,10 @@ return f = e.pointerId, oc.set(f, tc(oc.get(f) || null, a, b, c, d, e)), !0; } return !1; - })(f1, a10, b7, c3, d4)) return; + })(f1, a10, b7, c4, d4)) return; sc(a10, d4); } - jd(a10, b7, d4, null, c3); + jd(a10, b7, d4, null, c4); } } } @@ -12298,7 +12298,7 @@ passive: e }) : a.addEventListener(b, c, !1); } - function jd(a12, b9, c4, d5, e4) { + function jd(a12, b9, c5, d5, e4) { var f = d5; if (0 == (1 & b9) && 0 == (2 & b9) && null !== d5) a: for(;;){ if (null === d5) return; @@ -12331,14 +12331,14 @@ Lb = !1, Mb(); } }(function() { - var d = f, e = xb(c4), g = []; + var d = f, e = xb(c5), g = []; a: { var h = Mc.get(a12); if (void 0 !== h) { var k = td, x = a12; switch(a12){ case "keypress": - if (0 === od(c4)) break a; + if (0 === od(c5)) break a; case "keydown": case "keyup": k = Rd; @@ -12354,7 +12354,7 @@ k = Fd; break; case "click": - if (2 === c4.button) break a; + if (2 === c5.button) break a; case "auxclick": case "dblclick": case "mousedown": @@ -12417,7 +12417,7 @@ if (5 === q.tag && null !== v && (q = v, null !== u && null != (v = Ob(t, u)) && w.push(ef(t, v, q))), z) break; t = t.return; } - 0 < w.length && (h = new k(h, x, null, c4, e), g.push({ + 0 < w.length && (h = new k(h, x, null, c5, e), g.push({ event: h, listeners: w })); @@ -12425,9 +12425,9 @@ } if (0 == (7 & b9)) { a: { - if (h = "mouseover" === a12 || "pointerover" === a12, k = "mouseout" === a12 || "pointerout" === a12, h && 0 == (16 & b9) && (x = c4.relatedTarget || c4.fromElement) && (wc(x) || x[ff])) break a; - if ((k || h) && (h = e.window === e ? e : (h = e.ownerDocument) ? h.defaultView || h.parentWindow : window, k ? (x = c4.relatedTarget || c4.toElement, k = d, null !== (x = x ? wc(x) : null) && (z = Zb(x), x !== z || 5 !== x.tag && 6 !== x.tag) && (x = null)) : (k = null, x = d), k !== x)) { - if (w = Bd, v = "onMouseLeave", u = "onMouseEnter", t = "mouse", ("pointerout" === a12 || "pointerover" === a12) && (w = Td, v = "onPointerLeave", u = "onPointerEnter", t = "pointer"), z = null == k ? h : ue(k), q = null == x ? h : ue(x), (h = new w(v, t + "leave", k, c4, e)).target = z, h.relatedTarget = q, v = null, wc(e) === d && ((w = new w(u, t + "enter", x, c4, e)).target = q, w.relatedTarget = z, v = w), z = v, k && x) b: { + if (h = "mouseover" === a12 || "pointerover" === a12, k = "mouseout" === a12 || "pointerout" === a12, h && 0 == (16 & b9) && (x = c5.relatedTarget || c5.fromElement) && (wc(x) || x[ff])) break a; + if ((k || h) && (h = e.window === e ? e : (h = e.ownerDocument) ? h.defaultView || h.parentWindow : window, k ? (x = c5.relatedTarget || c5.toElement, k = d, null !== (x = x ? wc(x) : null) && (z = Zb(x), x !== z || 5 !== x.tag && 6 !== x.tag) && (x = null)) : (k = null, x = d), k !== x)) { + if (w = Bd, v = "onMouseLeave", u = "onMouseEnter", t = "mouse", ("pointerout" === a12 || "pointerover" === a12) && (w = Td, v = "onPointerLeave", u = "onPointerEnter", t = "pointer"), z = null == k ? h : ue(k), q = null == x ? h : ue(x), (h = new w(v, t + "leave", k, c5, e)).target = z, h.relatedTarget = q, v = null, wc(e) === d && ((w = new w(u, t + "enter", x, c5, e)).target = q, w.relatedTarget = z, v = w), z = v, k && x) b: { for(w = k, u = x, t = 0, q = w; q; q = gf(q))t++; for(q = 0, v = u; v; v = gf(v))q++; for(; 0 < t - q;)w = gf(w), t--; @@ -12451,7 +12451,7 @@ } else (k = h.nodeName) && "input" === k.toLowerCase() && ("checkbox" === h.type || "radio" === h.type) && (J = Ee); if (J && (J = J(a12, d))) { - ne(g, J, c4, e); + ne(g, J, c5, e); break a; } K && K(a12, h, d), "focusout" === a12 && (K = h._wrapperState) && K.controlled && "number" === h.type && bb(h, "number", h.value); @@ -12469,13 +12469,13 @@ case "contextmenu": case "mouseup": case "dragend": - Te = !1, Ue(g, c4, e); + Te = !1, Ue(g, c5, e); break; case "selectionchange": if (Pe) break; case "keydown": case "keyup": - Ue(g, c4, e); + Ue(g, c5, e); } if (ae) b: { switch(a12){ @@ -12491,11 +12491,11 @@ } L = void 0; } - else ie ? ge(a12, c4) && (L = "onCompositionEnd") : "keydown" === a12 && 229 === c4.keyCode && (L = "onCompositionStart"); - L && (de && "ko" !== c4.locale && (ie || "onCompositionStart" !== L ? "onCompositionEnd" === L && ie && (Q = nd()) : (ld = "value" in (kd = e) ? kd.value : kd.textContent, ie = !0)), 0 < (K = oe(d, L)).length && (L = new Ld(L, a12, null, c4, e), g.push({ + else ie ? ge(a12, c5) && (L = "onCompositionEnd") : "keydown" === a12 && 229 === c5.keyCode && (L = "onCompositionStart"); + L && (de && "ko" !== c5.locale && (ie || "onCompositionStart" !== L ? "onCompositionEnd" === L && ie && (Q = nd()) : (ld = "value" in (kd = e) ? kd.value : kd.textContent, ie = !0)), 0 < (K = oe(d, L)).length && (L = new Ld(L, a12, null, c5, e), g.push({ event: L, listeners: K - }), Q ? L.data = Q : null !== (Q = he(c4)) && (L.data = Q))), (Q = ce ? (function(a, b) { + }), Q ? L.data = Q : null !== (Q = he(c5)) && (L.data = Q))), (Q = ce ? (function(a, b) { switch(a){ case "compositionend": return he(b); @@ -12507,7 +12507,7 @@ default: return null; } - })(a12, c4) : (function(a, b) { + })(a12, c5) : (function(a, b) { if (ie) return "compositionend" === a || !ae && ge(a, b) ? (a = nd(), md = ld = kd = null, ie = !1, a) : null; switch(a){ case "paste": @@ -12523,7 +12523,7 @@ default: return null; } - })(a12, c4)) && 0 < (d = oe(d, "onBeforeInput")).length && (e = new Ld("onBeforeInput", "beforeinput", null, c4, e), g.push({ + })(a12, c5)) && 0 < (d = oe(d, "onBeforeInput")).length && (e = new Ld("onBeforeInput", "beforeinput", null, c5, e), g.push({ event: e, listeners: d }), e.data = Q); @@ -12998,7 +12998,7 @@ null !== d ? (d.nextEffect = c, b.lastEffect = c) : b.firstEffect = b.lastEffect = c, c.nextEffect = null, c.flags = 8; } } - function c5(c, d) { + function c6(c, d) { if (!a14) return null; for(; null !== d;)b11(c, d), d = d.sibling; return null; @@ -13083,17 +13083,17 @@ switch(k2.tag){ case 7: if (f.type === ua) { - c5(a15, k2.sibling), (d = e5(k2, f.props.children)).return = a15, a15 = d; + c6(a15, k2.sibling), (d = e5(k2, f.props.children)).return = a15, a15 = d; break a; } break; default: if (k2.elementType === f.type) { - c5(a15, k2.sibling), (d = e5(k2, f.props)).ref = Qg(a15, k2, f), d.return = a15, a15 = d; + c6(a15, k2.sibling), (d = e5(k2, f.props)).ref = Qg(a15, k2, f), d.return = a15, a15 = d; break a; } } - c5(a15, k2); + c6(a15, k2); break; } b11(a15, k2), k2 = k2.sibling; @@ -13105,10 +13105,10 @@ a: { for(k2 = f.key; null !== d;){ if (d.key === k2) if (4 === d.tag && d.stateNode.containerInfo === f.containerInfo && d.stateNode.implementation === f.implementation) { - c5(a15, d.sibling), (d = e5(d, f.children || [])).return = a15, a15 = d; + c6(a15, d.sibling), (d = e5(d, f.children || [])).return = a15, a15 = d; break a; } else { - c5(a15, d); + c6(a15, d); break; } b11(a15, d), d = d.sibling; @@ -13117,7 +13117,7 @@ } return g1(a15); } - if ("string" == typeof f || "number" == typeof f) return f = "" + f, null !== d && 6 === d.tag ? (c5(a15, d.sibling), (d = e5(d, f)).return = a15, a15 = d) : (c5(a15, d), (d = Ug(f, a15.mode, h2)).return = a15, a15 = d), g1(a15); + if ("string" == typeof f || "number" == typeof f) return f = "" + f, null !== d && 6 === d.tag ? (c6(a15, d.sibling), (d = e5(d, f)).return = a15, a15 = d) : (c6(a15, d), (d = Ug(f, a15.mode, h2)).return = a15, a15 = d), g1(a15); if (Pg(f)) return (function(e, g, h, k) { for(var l = null, t = null, u = g, z = g = 0, q = null; null !== u && z < h.length; z++){ u.index > z ? (q = u, u = null) : q = u.sibling; @@ -13128,7 +13128,7 @@ } a14 && u && null === n.alternate && b11(e, u), g = f4(n, g, z), null === t ? l = n : t.sibling = n, t = n, u = q; } - if (z === h.length) return c5(e, u), l; + if (z === h.length) return c6(e, u), l; if (null === u) { for(; z < h.length; z++)null !== (u = A(e, h[z], k)) && (g = f4(u, g, z), null === t ? l = u : t.sibling = u, t = u); return l; @@ -13151,7 +13151,7 @@ } a14 && u && null === w.alternate && b11(e, u), g = f4(w, g, z), null === t ? l = w : t.sibling = w, t = w, u = q; } - if (n.done) return c5(e, u), l; + if (n.done) return c6(e, u), l; if (null === u) { for(; !n.done; z++, n = h.next())null !== (n = A(e, n.value, k)) && (g = f4(n, g, z), null === t ? l = n : t.sibling = n, t = n); return l; @@ -13169,7 +13169,7 @@ case 15: throw Error(y(152, Ra(a15.type) || "Component")); } - return c5(a15, d); + return c6(a15, d); }; } var Yg = Sg(!0), Zg = Sg(!1), $g = {}, ah = Bf($g), bh = Bf($g), ch = Bf($g); @@ -13411,11 +13411,11 @@ if (null !== e ? a = e === d : (a = (xh & (a = a.mutableReadLanes)) === a) && (b._workInProgressVersionPrimary = d, th.push(b)), a) return c(b._source); throw th.push(b), Error(y(350)); } - function Nh(a16, b, c6, d7) { + function Nh(a16, b, c7, d7) { var e = U; if (null === e) throw Error(y(349)); var f = b._getVersion, g = f(b._source), h3 = vh.current, k3 = h3.useState(function() { - return Mh(e, b, c6); + return Mh(e, b, c7); }), l = k3[1], n = k3[0]; k3 = T; var A = a16.memoizedState, p = A.refs, C = p.getSnapshot, x = A.source; @@ -13426,17 +13426,17 @@ source: b, subscribe: d7 }, h3.useEffect(function() { - p.getSnapshot = c6, p.setSnapshot = l; + p.getSnapshot = c7, p.setSnapshot = l; var a = f(b._source); if (!He(g, a)) { - He(n, a = c6(b._source)) || (l(a), a = Ig(w), e.mutableReadLanes |= a & e.pendingLanes), a = e.mutableReadLanes, e.entangledLanes |= a; + He(n, a = c7(b._source)) || (l(a), a = Ig(w), e.mutableReadLanes |= a & e.pendingLanes), a = e.mutableReadLanes, e.entangledLanes |= a; for(var d = e.entanglements, h = a; 0 < h;){ var k = 31 - Vc(h), v = 1 << k; d[k] |= a, h &= ~v; } } }, [ - c6, + c7, b, d7 ]), h3.useEffect(function() { @@ -13455,12 +13455,12 @@ }, [ b, d7 - ]), He(C, c6) && He(x, b) && He(A, d7) || ((a16 = { + ]), He(C, c7) && He(x, b) && He(A, d7) || ((a16 = { pending: null, dispatch: null, lastRenderedReducer: Jh, lastRenderedState: n - }).dispatch = l = Oh.bind(null, R, a16), k3.queue = a16, k3.baseQueue = null, n = Mh(e, b, c6), k3.memoizedState = k3.baseState = n), n; + }).dispatch = l = Oh.bind(null, R, a16), k3.queue = a16, k3.baseQueue = null, n = Mh(e, b, c7), k3.memoizedState = k3.baseState = n), n; } function Ph(a, b, c) { return Nh(Ih(), a, b, c); @@ -13554,10 +13554,10 @@ ], a); } function di(a, b) { - var c7 = eg(); - gg(98 > c7 ? 98 : c7, function() { + var c8 = eg(); + gg(98 > c8 ? 98 : c8, function() { a(!0); - }), gg(97 < c7 ? 97 : c7, function() { + }), gg(97 < c8 ? 97 : c8, function() { var c = wh.transition; wh.transition = 1; try { @@ -14302,17 +14302,17 @@ Qi || (Qi = !0, Ri = d), Ni(a, b); }, c; } - function Si(a, b, c8) { - (c8 = zg(-1, c8)).tag = 3; + function Si(a, b, c9) { + (c9 = zg(-1, c9)).tag = 3; var d = a.type.getDerivedStateFromError; if ("function" == typeof d) { var e = b.value; - c8.payload = function() { + c9.payload = function() { return Ni(a, b), d(e); }; } var f = a.stateNode; - return null !== f && "function" == typeof f.componentDidCatch && (c8.callback = function() { + return null !== f && "function" == typeof f.componentDidCatch && (c9.callback = function() { "function" != typeof d && (null === Ti ? Ti = new Set([ this ]) : Ti.add(this), Ni(a, b)); @@ -14320,7 +14320,7 @@ this.componentDidCatch(b.value, { componentStack: null !== c ? c : "" }); - }), c8; + }), c9; } var Ui = "function" == typeof WeakSet ? WeakSet : Set; function Vi(a) { @@ -15430,8 +15430,8 @@ function rk(a) { return !(!a || 1 !== a.nodeType && 9 !== a.nodeType && 11 !== a.nodeType && (8 !== a.nodeType || " react-mount-point-unstable " !== a.nodeValue)); } - function tk(a21, b16, c9, d, e) { - var f = c9._reactRootContainer; + function tk(a21, b16, c10, d, e) { + var f = c10._reactRootContainer; if (f) { var g = f._internalRoot; if ("function" == typeof e) { @@ -15443,12 +15443,12 @@ } lk(b16, g, a21, e); } else { - if (g = (f = c9._reactRootContainer = (function(a, b) { + if (g = (f = c10._reactRootContainer = (function(a, b) { if (b || (b = !(!(b = a ? 9 === a.nodeType ? a.documentElement : a.firstChild : null) || 1 !== b.nodeType || !b.hasAttribute("data-reactroot"))), !b) for(var c; c = a.lastChild;)a.removeChild(c); return new qk(a, 0, b ? { hydrate: !0 } : void 0); - })(c9, d))._internalRoot, "function" == typeof e) { + })(c10, d))._internalRoot, "function" == typeof e) { var k = e; e = function() { var a = mk(g); @@ -16869,12 +16869,12 @@ var record = tryCatch(generator[method], generator, arg); if ("throw" === record.type) reject(record.arg); else { - var result = record.arg, value2 = result.value; - return value2 && "object" == typeof value2 && hasOwn.call(value2, "__await") ? PromiseImpl.resolve(value2.__await).then(function(value) { + var result = record.arg, value3 = result.value; + return value3 && "object" == typeof value3 && hasOwn.call(value3, "__await") ? PromiseImpl.resolve(value3.__await).then(function(value) { invoke("next", value, resolve, reject); }, function(err) { invoke("throw", err, resolve, reject); - }) : PromiseImpl.resolve(value2).then(function(unwrapped) { + }) : PromiseImpl.resolve(value3).then(function(unwrapped) { result.value = unwrapped, resolve(result); }, function(error) { return invoke("throw", error, resolve, reject); diff --git a/crates/swc_ecma_minifier/tests/compress/fixture/issues/firebase-core/1/output.js b/crates/swc_ecma_minifier/tests/compress/fixture/issues/firebase-core/1/output.js index a709df0c144..fe0dc5e695e 100644 --- a/crates/swc_ecma_minifier/tests/compress/fixture/issues/firebase-core/1/output.js +++ b/crates/swc_ecma_minifier/tests/compress/fixture/issues/firebase-core/1/output.js @@ -1799,9 +1799,9 @@ src2 = "string" == typeof src2 ? src2 : staticSrc; var widthInt = getInt(width), heightInt = getInt(height), qualityInt = getInt(quality), isLazy = !priority && ("lazy" === loading || void 0 === loading); (src2.startsWith("data:") || src2.startsWith("blob:")) && (unoptimized = !0, isLazy = !1), loadedImageURLs.has(src2) && (isLazy = !1); - var arr2, ref2 = function(arr) { + var arr3, ref2 = function(arr) { if (Array.isArray(arr)) return arr; - }(arr2 = _useIntersection.useIntersection({ + }(arr3 = _useIntersection.useIntersection({ rootMargin: lazyBoundary, disabled: !isLazy })) || function(arr, i) { @@ -1818,7 +1818,7 @@ } } return _arr; - }(arr2, 2) || function() { + }(arr3, 2) || function() { throw new TypeError("Invalid attempt to destructure non-iterable instance"); }(), setRef = ref2[0], isIntersected = ref2[1], wrapperStyle = { boxSizing: "border-box", @@ -2132,9 +2132,9 @@ Object.defineProperty(exports, "__esModule", { value: !0 }), exports.useIntersection = function(param) { - var arr3, rootMargin = param.rootMargin, isDisabled = param.disabled || !hasIntersectionObserver, unobserve = _react.useRef(), ref = function(arr) { + var arr4, rootMargin = param.rootMargin, isDisabled = param.disabled || !hasIntersectionObserver, unobserve = _react.useRef(), ref = function(arr) { if (Array.isArray(arr)) return arr; - }(arr3 = _react.useState(!1)) || function(arr, i) { + }(arr4 = _react.useState(!1)) || function(arr, i) { var _arr = [], _n = !0, _d = !1, _e = void 0; try { for(var _s, _i = arr[Symbol.iterator](); !(_n = (_s = _i.next()).done) && (_arr.push(_s.value), !i || _arr.length !== i); _n = !0); @@ -2148,7 +2148,7 @@ } } return _arr; - }(arr3, 2) || function() { + }(arr4, 2) || function() { throw new TypeError("Invalid attempt to destructure non-iterable instance"); }(), visible = ref[0], setVisible = ref[1], setRef = _react.useCallback(function(el) { unobserve.current && (unobserve.current(), unobserve.current = void 0), !isDisabled && !visible && el && el.tagName && (unobserve.current = observe(el, function(isVisible) { diff --git a/crates/swc_ecma_minifier/tests/compress/fixture/issues/quagga2/1.4.2/1/output.js b/crates/swc_ecma_minifier/tests/compress/fixture/issues/quagga2/1.4.2/1/output.js index 5d9f1ad9e80..8b43fd85408 100644 --- a/crates/swc_ecma_minifier/tests/compress/fixture/issues/quagga2/1.4.2/1/output.js +++ b/crates/swc_ecma_minifier/tests/compress/fixture/issues/quagga2/1.4.2/1/output.js @@ -1140,10 +1140,10 @@ }; }, function(module, exports) { - function _setPrototypeOf(o2, p1) { + function _setPrototypeOf(o2, p3) { return module.exports = _setPrototypeOf = Object.setPrototypeOf || function(o, p) { return o.__proto__ = p, o; - }, module.exports.default = module.exports, module.exports.__esModule = !0, _setPrototypeOf(o2, p1); + }, module.exports.default = module.exports, module.exports.__esModule = !0, _setPrototypeOf(o2, p3); } module.exports = _setPrototypeOf, module.exports.default = module.exports, module.exports.__esModule = !0; }, diff --git a/crates/swc_ecma_minifier/tests/compress/fixture/issues/react-countup/1/output.js b/crates/swc_ecma_minifier/tests/compress/fixture/issues/react-countup/1/output.js index 86ad3d53e34..119ace978cb 100644 --- a/crates/swc_ecma_minifier/tests/compress/fixture/issues/react-countup/1/output.js +++ b/crates/swc_ecma_minifier/tests/compress/fixture/issues/react-countup/1/output.js @@ -131,9 +131,9 @@ src2 = "string" == typeof src2 ? src2 : staticSrc; var widthInt = getInt(width), heightInt = getInt(height), qualityInt = getInt(quality), isLazy = !priority && ("lazy" === loading || void 0 === loading); (src2.startsWith("data:") || src2.startsWith("blob:")) && (unoptimized = !0, isLazy = !1), loadedImageURLs.has(src2) && (isLazy = !1); - var arr2, ref2 = function(arr) { + var arr3, ref2 = function(arr) { if (Array.isArray(arr)) return arr; - }(arr2 = _useIntersection.useIntersection({ + }(arr3 = _useIntersection.useIntersection({ rootMargin: lazyBoundary, disabled: !isLazy })) || function(arr, i) { @@ -150,7 +150,7 @@ } } return _arr; - }(arr2, 2) || function() { + }(arr3, 2) || function() { throw new TypeError("Invalid attempt to destructure non-iterable instance"); }(), setRef = ref2[0], isIntersected = ref2[1], wrapperStyle = { boxSizing: "border-box", @@ -464,9 +464,9 @@ Object.defineProperty(exports, "__esModule", { value: !0 }), exports.useIntersection = function(param) { - var arr3, rootMargin = param.rootMargin, isDisabled = param.disabled || !hasIntersectionObserver, unobserve = _react.useRef(), ref = function(arr) { + var arr4, rootMargin = param.rootMargin, isDisabled = param.disabled || !hasIntersectionObserver, unobserve = _react.useRef(), ref = function(arr) { if (Array.isArray(arr)) return arr; - }(arr3 = _react.useState(!1)) || function(arr, i) { + }(arr4 = _react.useState(!1)) || function(arr, i) { var _arr = [], _n = !0, _d = !1, _e = void 0; try { for(var _s, _i = arr[Symbol.iterator](); !(_n = (_s = _i.next()).done) && (_arr.push(_s.value), !i || _arr.length !== i); _n = !0); @@ -480,7 +480,7 @@ } } return _arr; - }(arr3, 2) || function() { + }(arr4, 2) || function() { throw new TypeError("Invalid attempt to destructure non-iterable instance"); }(), visible = ref[0], setVisible = ref[1], setRef = _react.useCallback(function(el) { unobserve.current && (unobserve.current(), unobserve.current = void 0), !isDisabled && !visible && el && el.tagName && (unobserve.current = observe(el, function(isVisible) { diff --git a/crates/swc_ecma_minifier/tests/compress/fixture/next/31077/static/chunks/1606726a.10299989c08cb523/output.js b/crates/swc_ecma_minifier/tests/compress/fixture/next/31077/static/chunks/1606726a.10299989c08cb523/output.js index a2728d8bbb0..33473ed8e28 100644 --- a/crates/swc_ecma_minifier/tests/compress/fixture/next/31077/static/chunks/1606726a.10299989c08cb523/output.js +++ b/crates/swc_ecma_minifier/tests/compress/fixture/next/31077/static/chunks/1606726a.10299989c08cb523/output.js @@ -2390,10 +2390,10 @@ return; } view8.domChangeCount++, view8.state.selection.from < view8.state.selection.to && change.start == change.endB && view8.state.selection instanceof prosemirror_state__WEBPACK_IMPORTED_MODULE_0__.TextSelection && (change.start > view8.state.selection.from && change.start <= view8.state.selection.from + 2 ? change.start = view8.state.selection.from : change.endA < view8.state.selection.to && change.endA >= view8.state.selection.to - 2 && (change.endB += view8.state.selection.to - change.endA, change.endA = view8.state.selection.to)), result1.ie && result1.ie_version <= 11 && change.endB == change.start + 1 && change.endA == change.start && change.start > parse.from && " \xa0" == parse.doc.textBetween(change.start - parse.from - 1, change.start - parse.from + 1) && (change.start--, change.endA--, change.endB--); - var $from1 = parse.doc.resolveNoCache(change.start - parse.from), $to = parse.doc.resolveNoCache(change.endB - parse.from), inlineChange = $from1.sameParent($to) && $from1.parent.inlineContent; + var $from2 = parse.doc.resolveNoCache(change.start - parse.from), $to = parse.doc.resolveNoCache(change.endB - parse.from), inlineChange = $from2.sameParent($to) && $from2.parent.inlineContent; if ((result1.ios && view8.lastIOSEnter > Date.now() - 225 && (!inlineChange || addedNodes.some(function(n) { return "DIV" == n.nodeName || "P" == n.nodeName; - })) || !inlineChange && $from1.pos < parse.doc.content.size && (nextSel = prosemirror_state__WEBPACK_IMPORTED_MODULE_0__.Selection.findFrom(parse.doc.resolve($from1.pos + 1), 1, !0)) && nextSel.head == $to.pos) && view8.someProp("handleKeyDown", function(f) { + })) || !inlineChange && $from2.pos < parse.doc.content.size && (nextSel = prosemirror_state__WEBPACK_IMPORTED_MODULE_0__.Selection.findFrom(parse.doc.resolve($from2.pos + 1), 1, !0)) && nextSel.head == $to.pos) && view8.someProp("handleKeyDown", function(f) { return f(view8, keyEvent(13, "Enter")); })) { view8.lastIOSEnter = 0; @@ -2405,20 +2405,20 @@ if ($start.parentOffset < $start.parent.content.size || !$start.parent.isTextblock) return !1; var $next = old.resolve(skipClosingAndOpening($start, !0, !0)); return !(!$next.parent.isTextblock || $next.pos > end || skipClosingAndOpening($next, !0, !1) < end) && $newStart.parent.content.cut($newStart.parentOffset).eq($next.parent.content); - })(doc1, change.start, change.endA, $from1, $to) && view8.someProp("handleKeyDown", function(f) { + })(doc1, change.start, change.endA, $from2, $to) && view8.someProp("handleKeyDown", function(f) { return f(view8, keyEvent(8, "Backspace")); })) { result1.android && result1.chrome && view8.domObserver.suppressSelectionUpdates(); return; } - result1.chrome && result1.android && change.toB == change.from && (view8.lastAndroidDelete = Date.now()), result1.android && !inlineChange && $from1.start() != $to.start() && 0 == $to.parentOffset && $from1.depth == $to.depth && parse.sel && parse.sel.anchor == parse.sel.head && parse.sel.head == change.endA && (change.endB -= 2, $to = parse.doc.resolveNoCache(change.endB - parse.from), setTimeout(function() { + result1.chrome && result1.android && change.toB == change.from && (view8.lastAndroidDelete = Date.now()), result1.android && !inlineChange && $from2.start() != $to.start() && 0 == $to.parentOffset && $from2.depth == $to.depth && parse.sel && parse.sel.anchor == parse.sel.head && parse.sel.head == change.endA && (change.endB -= 2, $to = parse.doc.resolveNoCache(change.endB - parse.from), setTimeout(function() { view8.someProp("handleKeyDown", function(f) { return f(view8, keyEvent(13, "Enter")); }); }, 20)); var chFrom = change.start, chTo = change.endA; if (inlineChange) { - if ($from1.pos == $to.pos) result1.ie && result1.ie_version <= 11 && 0 == $from1.parentOffset && (view8.domObserver.suppressSelectionUpdates(), setTimeout(function() { + if ($from2.pos == $to.pos) result1.ie && result1.ie_version <= 11 && 0 == $from2.parentOffset && (view8.domObserver.suppressSelectionUpdates(), setTimeout(function() { return selectionToDOM(view8); }, 20)), tr = view8.state.tr.delete(chFrom, chTo), storedMarks = doc1.resolve(change.start).marksAcross(doc1.resolve(change.endA)); else if (change.endA == change.endB && ($from1 = doc1.resolve(change.start)) && (markChange = (function(cur, prev) { @@ -2438,9 +2438,9 @@ mark: mark, type: type }; - })($from1.parent.content.cut($from1.parentOffset, $to.parentOffset), $from1.parent.content.cut($from1.parentOffset, change.endA - $from1.start())))) tr = view8.state.tr, "add" == markChange.type ? tr.addMark(chFrom, chTo, markChange.mark) : tr.removeMark(chFrom, chTo, markChange.mark); - else if ($from1.parent.child($from1.index()).isText && $from1.index() == $to.index() - ($to.textOffset ? 0 : 1)) { - var text$1 = $from1.parent.textBetween($from1.parentOffset, $to.parentOffset); + })($from2.parent.content.cut($from2.parentOffset, $to.parentOffset), $from1.parent.content.cut($from1.parentOffset, change.endA - $from1.start())))) tr = view8.state.tr, "add" == markChange.type ? tr.addMark(chFrom, chTo, markChange.mark) : tr.removeMark(chFrom, chTo, markChange.mark); + else if ($from2.parent.child($from2.index()).isText && $from2.index() == $to.index() - ($to.textOffset ? 0 : 1)) { + var text$1 = $from2.parent.textBetween($from2.parentOffset, $to.parentOffset); if (view8.someProp("handleTextInput", function(f) { return f(view8, chFrom, chTo, text$1); })) return; diff --git a/crates/swc_ecma_minifier/tests/compress/fixture/next/feedback-2/codemirror/output.js b/crates/swc_ecma_minifier/tests/compress/fixture/next/feedback-2/codemirror/output.js index 35c0c6e152c..87fe5425b04 100644 --- a/crates/swc_ecma_minifier/tests/compress/fixture/next/feedback-2/codemirror/output.js +++ b/crates/swc_ecma_minifier/tests/compress/fixture/next/feedback-2/codemirror/output.js @@ -4425,19 +4425,19 @@ var dx = other.left - touch.left, dy = other.top - touch.top; return dx * dx + dy * dy > 400; } - on1(d.scroller, "touchstart", function(e2) { - if (!signalDOMEvent(cm9, e2) && !function(e) { + on1(d.scroller, "touchstart", function(e3) { + if (!signalDOMEvent(cm9, e3) && !function(e) { if (1 != e.touches.length) return !1; var touch = e.touches[0]; return touch.radiusX <= 1 && touch.radiusY <= 1; - }(e2) && !clickInGutter(cm9, e2)) { + }(e3) && !clickInGutter(cm9, e3)) { d.input.ensurePolled(), clearTimeout(touchFinished); var now = +new Date; d.activeTouch = { start: now, moved: !1, prev: now - prevTouch.end <= 300 ? prevTouch : null - }, 1 == e2.touches.length && (d.activeTouch.left = e2.touches[0].pageX, d.activeTouch.top = e2.touches[0].pageY); + }, 1 == e3.touches.length && (d.activeTouch.left = e3.touches[0].pageX, d.activeTouch.top = e3.touches[0].pageY); } }), on1(d.scroller, "touchmove", function() { d.activeTouch && (d.activeTouch.moved = !0); @@ -4460,16 +4460,16 @@ enter: function(e) { signalDOMEvent(cm9, e) || e_stop(e); }, - over: function(e3) { - signalDOMEvent(cm9, e3) || ((function(cm, e) { + over: function(e4) { + signalDOMEvent(cm9, e4) || ((function(cm, e) { var pos = posFromMouse(cm, e); if (pos) { var frag = document.createDocumentFragment(); drawSelectionCursor(cm, pos, frag), cm.display.dragCursor || (cm.display.dragCursor = elt1("div", null, "CodeMirror-cursors CodeMirror-dragcursors"), cm.display.lineSpace.insertBefore(cm.display.dragCursor, cm.display.cursorDiv)), removeChildrenAndAdd(cm.display.dragCursor, frag); } - })(cm9, e3), e_stop(e3)); + })(cm9, e4), e_stop(e4)); }, - start: function(e4) { + start: function(e5) { return (function(cm, e) { if (ie && (!cm.state.draggingText || +new Date - lastDrop < 100)) { e_stop(e); @@ -4479,7 +4479,7 @@ var img = elt1("img", null, null, "position: fixed; left: 0; top: 0;"); img.src = "data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==", presto && (img.width = img.height = 1, cm.display.wrapper.appendChild(img), img._top = img.offsetTop), e.dataTransfer.setDragImage(img, 0, 0), presto && img.parentNode.removeChild(img); } - })(cm9, e4); + })(cm9, e5); }, drop: operation(cm9, onDrop), leave: function(e) { diff --git a/crates/swc_ecma_minifier/tests/projects/output/angular-1.2.5.js b/crates/swc_ecma_minifier/tests/projects/output/angular-1.2.5.js index 787ad88f646..98599d098a7 100644 --- a/crates/swc_ecma_minifier/tests/projects/output/angular-1.2.5.js +++ b/crates/swc_ecma_minifier/tests/projects/output/angular-1.2.5.js @@ -1956,8 +1956,8 @@ return logFn.apply ? function() { var args = []; return forEach(arguments, function(arg) { - var arg1; - args.push(((arg1 = arg) instanceof Error && (arg1.stack ? arg1 = arg1.message && -1 === arg1.stack.indexOf(arg1.message) ? "Error: " + arg1.message + "\n" + arg1.stack : arg1.stack : arg1.sourceURL && (arg1 = arg1.message + "\n" + arg1.sourceURL + ":" + arg1.line)), arg1)); + var arg4; + args.push(((arg4 = arg) instanceof Error && (arg4.stack ? arg4 = arg4.message && -1 === arg4.stack.indexOf(arg4.message) ? "Error: " + arg4.message + "\n" + arg4.stack : arg4.stack : arg4.sourceURL && (arg4 = arg4.message + "\n" + arg4.sourceURL + ":" + arg4.line)), arg4)); }), logFn.apply(console, args); } : function(arg1, arg2) { logFn(arg1, null == arg2 ? "" : arg2); diff --git a/crates/swc_ecma_minifier/tests/projects/output/yui-3.12.0.js b/crates/swc_ecma_minifier/tests/projects/output/yui-3.12.0.js index d460cd0a781..4aad8842b86 100644 --- a/crates/swc_ecma_minifier/tests/projects/output/yui-3.12.0.js +++ b/crates/swc_ecma_minifier/tests/projects/output/yui-3.12.0.js @@ -1380,7 +1380,7 @@ var YUI = function() { return !!rm && mod2 in rm || !!m.ext && "css" === m.type && !other.ext && "css" === other.type; }, _config: function(o) { - var i, j, val, a, f, group, groupName, mod1, self = this, mods = []; + var i, j, val, a, f, group, groupName, mod3, self = this, mods = []; if (o) { for(i in o)if (o.hasOwnProperty(i)) if (val = o[i], "require" === i) self.require(val); else if ("skin" === i) "string" == typeof val && (self.skin.defaultSkin = o.skin, val = { @@ -1393,7 +1393,7 @@ var YUI = function() { else "gallery" === i ? this.groups.gallery.update && this.groups.gallery.update(val, o) : "yui2" === i || "2in3" === i ? this.groups.yui2.update && this.groups.yui2.update(o["2in3"], o.yui2, o) : self[i] = val; } if (f = self.filter, L.isString(f) && (f = f.toUpperCase(), self.filterName = f, self.filter = self.FILTER_DEFS[f], "DEBUG" === f && self.require("yui-log", "dump")), self.filterName && self.coverage && "COVERAGE" === self.filterName && L.isArray(self.coverage) && self.coverage.length) { - for(i = 0; i < self.coverage.length; i++)mod1 = self.coverage[i], self.moduleInfo[mod1] && self.moduleInfo[mod1].use ? mods = [].concat(mods, self.moduleInfo[mod1].use) : mods.push(mod1); + for(i = 0; i < self.coverage.length; i++)mod3 = self.coverage[i], self.moduleInfo[mod3] && self.moduleInfo[mod3].use ? mods = [].concat(mods, self.moduleInfo[mod3].use) : mods.push(mod3); self.filters = self.filters || {}, Y.Array.each(mods, function(mod) { self.filters[mod] = self.FILTER_DEFS.COVERAGE; }), self.filterName = "RAW", self.filter = self.FILTER_DEFS[self.filterName]; diff --git a/crates/swc_ecma_transforms_base/src/hygiene/ops.rs b/crates/swc_ecma_transforms_base/src/hygiene/ops.rs index db23bb422c5..35aaafe5039 100644 --- a/crates/swc_ecma_transforms_base/src/hygiene/ops.rs +++ b/crates/swc_ecma_transforms_base/src/hygiene/ops.rs @@ -29,6 +29,10 @@ impl Operations { } } + pub fn add_used(&mut self, sym: JsWord) { + self.symbols.insert(sym); + } + #[inline] pub fn get_renamed(&self, i: &Id) -> Option { self.rename.get(i).cloned() diff --git a/crates/swc_ecma_transforms_base/src/hygiene/usage_analyzer.rs b/crates/swc_ecma_transforms_base/src/hygiene/usage_analyzer.rs index 13ec5369966..34c91292967 100644 --- a/crates/swc_ecma_transforms_base/src/hygiene/usage_analyzer.rs +++ b/crates/swc_ecma_transforms_base/src/hygiene/usage_analyzer.rs @@ -314,6 +314,8 @@ impl UsageAnalyzer<'_> { trace!("Decl: `{}{:?}`", id.0, id.1); } + self.data.ops.borrow_mut().add_used(id.0.clone()); + let id = self.get_renamed_id(id); let need_rename = { @@ -354,6 +356,8 @@ impl UsageAnalyzer<'_> { trace!("Usage: `{}{:?}`", id.0, id.1); } + self.data.ops.borrow_mut().add_used(id.0.clone()); + let id = self.get_renamed_id(id); // We rename based on the scope depth of the identifier