Hi. I’m trying to reduce the size of the javascript I’m deploying, for a project I’m developing in kotlin.js.
So far I used kotlin-dce-js
with good results; now I’d like to minify the resulting javascript(s).
Since I’m using Gradle, I imported the eriwen/gradle-js-plugin
, that uses Google’s Closure Compiler to minify files. If I apply it to the (DCE’d) kotlin.js
, I get a number of errors like this:
[…]\build\kotlin-js-min\main\kotlin.js:3387 - Parse error. identifier is a reserved word
This is because of methods like this:
function digitOf(char, radix) {
var tmp$;
if (char >= (48 | 0) && char <= (57 | 0))
tmp$ = char - 48;
else if (char >= (65 | 0) && char <= (90 | 0))
tmp$ = char - 65 + 10 | 0;
else if (char >= (97 | 0) && char <= (122 | 0))
tmp$ = char - 97 + 10 | 0;
else
tmp$ = -1;
var it = tmp$;
return it >= radix ? -1 : it;
}
I understand that char is a reserved word in Javascript, or at least that the Closure Compiler thinks it is; my question is: is it possible to do something to rename those char
s at the Kotlin level? I can’t find a way to make the compiler ignore them.
Thanks!
– Germano
PS: uglify.js doesn’t complain, but I can’t find a way to integrate it into Gradle.