-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(es/minifier): Abort property hoisting on
eval
(#8957)
**Description:** - Repro: https://github.com/kdy1/repro-next-46887-2 **Related issue:** - vercel/next.js#46887 (comment)
- Loading branch information
Showing
3 changed files
with
79 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
crates/swc_ecma_minifier/tests/fixture/next/46887-2/input.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
var Za = { | ||
set: Qi, | ||
get: Qg, | ||
enforce: function (e1) { | ||
return Ri(e1) ? Qg(e1) : Qi(e1, {}); | ||
}, | ||
getterFor: function (e1) { | ||
return function (t) { | ||
var n; | ||
if (!ha(t) || (n = Qg(t)).type !== e1) throw TypeError("Incompatible receiver, " + e1 + " required"); | ||
return n; | ||
}; | ||
} | ||
} | ||
|
||
export function exposed() { | ||
try { | ||
var a = eval("quire".replace(/^/, "re"))(c); | ||
if (a && (a.length || Object.keys(a).length)) return a; | ||
} catch (e1) { } | ||
return null; | ||
} | ||
|
||
export default (function (e) { | ||
var t = Za.get, | ||
n = Za.enforce, | ||
r = String(String).split("String"); | ||
(e.exports = function (e, t, i, o) { | ||
var a = !!o && !!o.unsafe, | ||
s = !!o && !!o.enumerable; | ||
if (o = !!o && !!o.noTargetGet, "function" == typeof i) { | ||
"string" != typeof t || Q(i, "name") || Na(i, "name", t); | ||
var u = n(i); | ||
u.source || (u.source = r.join("string" == typeof t ? t : "")) | ||
} | ||
e === y ? s ? e[t] = i : Oi(t, i) : (a ? !o && e[t] && (s = !0) : delete e[t], s ? e[t] = i : Na(e, t, i)) | ||
})(Function.prototype, "toString", (function () { | ||
return "function" == typeof this && t(this).source || Pi(this) | ||
})) | ||
}) |
35 changes: 35 additions & 0 deletions
35
crates/swc_ecma_minifier/tests/fixture/next/46887-2/output.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
var Za = { | ||
set: Qi, | ||
get: Qg, | ||
enforce: function(e1) { | ||
return Ri(e1) ? Qg(e1) : Qi(e1, {}); | ||
}, | ||
getterFor: function(e1) { | ||
return function(t) { | ||
var n; | ||
if (!ha(t) || (n = Qg(t)).type !== e1) throw TypeError("Incompatible receiver, " + e1 + " required"); | ||
return n; | ||
}; | ||
} | ||
}; | ||
export function exposed() { | ||
try { | ||
var a = eval("quire".replace(/^/, "re"))(c); | ||
if (a && (a.length || Object.keys(a).length)) return a; | ||
} catch (e1) {} | ||
return null; | ||
} | ||
export default function(e) { | ||
var t = Za.get, n = Za.enforce, r = String(String).split("String"); | ||
(e.exports = function(e, t, i, o) { | ||
var a = !!o && !!o.unsafe, s = !!o && !!o.enumerable; | ||
if (o = !!o && !!o.noTargetGet, "function" == typeof i) { | ||
"string" != typeof t || Q(i, "name") || Na(i, "name", t); | ||
var u = n(i); | ||
u.source || (u.source = r.join("string" == typeof t ? t : "")); | ||
} | ||
e === y ? s ? e[t] = i : Oi(t, i) : (a ? !o && e[t] && (s = !0) : delete e[t], s ? e[t] = i : Na(e, t, i)); | ||
})(Function.prototype, "toString", function() { | ||
return "function" == typeof this && t(this).source || Pi(this); | ||
}); | ||
} |