Google closure-compiler goes a bit haywire for stuff like this :
const SomeFunc = (i,k,x) => i * i + k * x
console.log(someFunc(2))
someFunc(3)
someFunc(10)
someFunc(21)
someFunc(123)
someFunc(12314)
someFunc(123144)
console.log(someFunc(2));someFunc(3);someFunc(10);someFunc(21);someFunc(123);someFunc(12314);someFunc(123144);
The only happens when I run this on advanced optimization
On a side note : ES5+ is not supported even though we are now well on our way to ES9 ? (Kindly implement some basic ES6 functionalities).
For now this happens :
const xyz = () => // the whole code you know what
compiles to
var xyz = function() {};
Similarly spread operators , string literals or any other ES5+ functionality is not supported at all.
In your example, the function name is capitalized inconsistently (SomeFunc vs someFunc).
To enable ES6 output, set e.g. a --language_out ECMASCRIPT_2015 flag (or the @language_out ECMASCRIPT_2015 option in https://closure-compiler.appspot.com).
@tjgq :
So closure compiler won't accept functions with inconsistent capitalization ?
is there a reason for that ? (Just cruious)
Thanks for informing me of that
It's not about Closure, it's just JS. Identifiers are case sensitive.
@lazarljubenovic :
What does JS being case sensitive got anything to do with Closure , closure is compressing the code not finding the grammar mistake in it
Closure sees that you do not use SomeFunc, so it removes it. It analyzes the code and in order to minify is properly it has to be correct JavaScript. It's done exactly what it was supposed to do in your example.
@lazarljubenovic : My bad I didn't see it thanks. :)