28

I have a weird issue related to JavaScript minification, the problem is that when placing JavaScript files such as test1.js, test2.js inside /assets/javascript/test folder and using following options for closure compiler:

val defaultOptions = new CompilerOptions()
    defaultOptions.closurePass = true
    defaultOptions.setProcessCommonJSModules(false)
    defaultOptions.setPrettyPrint(true)
    CompilationLevel.WHITESPACE_ONLY.setOptionsForCompilationLevel(defaultOptions)

They get minified, but this will cause both test1.min.js and test2.min.js files to share same codes as minified... this will cause some additional JavaScript bugs when files are used within same pages and takes up more disk space.

However, if CompilerOptions is not set, JavaScript compiles properly without duplication but the compilation level is too strict and our JavaScript stops working because it says errors about some things written in those files. Overall, minification process is activated too late to fix all project js files to go through with default compiler options so only option now is to configure it to work in a way which use light minification but without js duplication.. any help on this issue will be highly appreciated!

I'm using Play Framework 2.1.1 with Java project.

Charles
  • 50,943
  • 13
  • 104
  • 142
Mauno Vähä
  • 9,688
  • 3
  • 33
  • 54
  • 1
    Did you ever find an answer to this? – shuttj Jan 02 '14 at 22:50
  • 1
    After more digging, I found this issue for play 2.2.1: https://github.com/playframework/playframework/issues/2192 – shuttj Jan 03 '14 at 03:47
  • 1
    Yea, I haven't had time to work it with lately, although we came up with some seriously big hack to workaround this issue, if 2.2.1 has it fixed it would be worth to try and accept it as solution instead. – Mauno Vähä Jan 03 '14 at 07:54

2 Answers2

1

It seems that this topic has generated some interests, I wan't to point out that I couldn't reproduce this problem after upgrading to play version 2.2.2. So I will be accepting this as a solution because it seems less hacky way to fix it.

Mauno Vähä
  • 9,688
  • 3
  • 33
  • 54
0

Upgrade the Play Framework to 2.2.2

WonderWorker
  • 8,539
  • 4
  • 63
  • 74