Invalid minification of computed method names
Closed this issue · 4 comments
IJMacD commented
test.js
const a = {name:"key"};
const b = {
[a.name] () { return 10; }
};
console.log(b.key());
Output:
10
Minify:
> npx minify@latest test.js
Minify Ouput:
var a={name:"key"},b={a.name(){return 10}};console.log(b.key());
JS Error:
Uncaught SyntaxError: Unexpected token '.'
Correct minified output:
var a={name:"key"},b={[a.name](){return 10}};console.log(b.key());
coderaiser commented
Please re-install Minify and try again.
Is it works for you?
IJMacD commented
Yes, thank you. Working in latest version.
IJMacD commented
The issue seems to have been fixed in object literals but not in classes.
Here's another failing test case:
const a = {name:"key"};
class B {
[a.name] () { return 10; }
};
console.log(new B().key());
coderaiser commented
Thank you! Just fixed, is it works for you?