This may be a better question for terser, but seeing as I'm using it through microbundle, I figured I'd start here. 😅
With the current (undocumented) mangling options available in microbundle, is it possible to tell terser to mangle Function prototypes? (To be clear, this is how I'm writing it, but I know it turns back into a pumpkin/Function once buble makes its pass.)
class Hello {
constructor(name) {
this.name = name;
}
sayName() {
console.log(this.allCaps_(this.name));
}
allCaps_(str) { // I want *this* to get mangled away
return str.toUpperCase();
}
}
I tried to add this to my package.json but had no luck. (If the problem is my regex I shall live in shame forever.)
{
"mangle": {
"regex": "/_$/"
}
}
FWIW — I could get it to hulk smash everything by passing this in, so at a minimum I've found one way to reach into that Function and mangle away, now just have to stop it from smashing everything. 😎
{
"mangle": {}
}
May have figured it out?
I think my extra slashes were doing it. This finally took:
{
"mangle": {
"regex": "_$"
}
}
oh yeah, you probably don't want those slashes in a string
I've added docs to the readme explaining this :)
@developit Awesome, thanks!
Though I have noticed something I don't quite understand — I get an empty file called mangle.json output into my root directory, but (so far) I've never seen it be anything other than {}. Should it be doing that at all? Should I be committing it?