swc
swc copied to clipboard
Helpers break on top-level `eval`
Describe the bug
When a variable is assigned to eval
function, _setPrototypeOf
will be removed by the mangler. This will cause a runtime error.
Input code
class A {
constructor(A) {}
}
class B extends A {
constructor(B) { super(B) }
}
const C = eval;
new B()
Config
{
"jsc": {
"parser": {
"syntax": "ecmascript"
},
"target": "es5",
"minify": {
"compress": false,
"mangle": true
},
"loose": false
},
"minify": true
}
Playground link
https://play.swc.rs/?version=1.2.224&code=H4sIAAAAAAAAA0vOSSwuVnBUqOZSUEjOzysuKSpNLskv0nDUVKiu5arlSgbLOymkVpSk5qVgU%2BkEVKlQXFqQCmaC9YBkFZwVbBVSyxJzrLnyUssVnDQ0AbMGxVtrAAAA&config=H4sIAAAAAAAAA0WLywqEMBAE%2F6XPXr3kb4YwkUheTM%2FCivjvmmXBW9NVdWJnRDgxxKg2F4%2Fm8kWAxiqMlofjWuBim%2Fq8uWJBzS2nY%2Fqx12FKIiQp1AdJ24oiuH30CUvv1D%2B83vBHb9xqQbR%2FAAAA
Expected behavior
No runtime error.
Actual behavior
Uncaught ReferenceError: _setPrototypeOf is not defined
Version
1.2.224
Additional context
No response
I think we should apply helper injector before the minifier...