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(mangle): handle inferred names for functions #842
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -196,4 +196,59 @@ describe("preset along with env", () => { | |
console.log(foo); | ||
` | ||
); | ||
|
||
thePlugin( | ||
"should fix issue#829 mangling after function name", | ||
` | ||
function foo() { | ||
let con = console; | ||
|
||
return { | ||
a(bar) { | ||
con.log(bar); | ||
} | ||
}; | ||
} | ||
`, | ||
` | ||
function foo() { | ||
var b = console; | ||
return { | ||
a: function d(c) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shouldn’t this be There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Handled by There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shouldn’t we strip the name then? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes. Correct. Deadcode should have taken care of that (have to debug why it didn't in this case), and we come back to plugin ordering problem - #422 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I guess it's the same issue as this one - we have to add the same thing in DCE (register this binding before dce runs). |
||
b.log(c); | ||
} | ||
}; | ||
} | ||
` | ||
); | ||
|
||
thePlugin( | ||
"should fix issue#829 mangling after function name 2", | ||
` | ||
function bar() { | ||
var b = console; | ||
return { | ||
a: class { | ||
constructor(bar) { | ||
b.log(bar); | ||
} | ||
} | ||
}; | ||
} | ||
`, | ||
` | ||
function _classCallCheck(a, b) { if (!(a instanceof b)) throw new TypeError(\"Cannot call a class as a function\"); } | ||
|
||
function bar() { | ||
var c = console; | ||
return { | ||
a: function b(a) { | ||
"use strict"; | ||
|
||
_classCallCheck(this, b), c.log(a); | ||
} | ||
}; | ||
} | ||
` | ||
); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unused.