eriwen / gradle-js-plugin

Gradle plugin for working with JS
http://eriwen.github.io/gradle-js-plugin
Apache License 2.0
382 stars 113 forks source link

Upgrade Closure Compiler to avoid kotlin minification errors #160

Open proofrock opened 6 years ago

proofrock commented 6 years ago

I’m trying to reduce the size of the javascript I’m deploying, for a project I’m developing in kotlin/js.

Since I’m using Gradle, I imported this plugin. 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;
    }

On the other hand, I tried also with the online service (https://closure-compiler.appspot.com/home), and actually it doesn’t complain. So it seems that the problem was solved upstream; but I dont know how (if it's even possible) to use a newer version of CC with the plugin.

Thanks,

--Germano

PS: reported also in kotlin forum, here