valueerror Posted January 22, 2015 Share Posted January 22, 2015 i tried yui-compressor and googles closure-compiler and both stop because of the word static.. finishline.body.static=true;or any other occurrence of the word static.. they simply throw an error.. wth? closure-compiler: test.js:945: ERROR - Parse error. missing name after . operator finishline.body.static=true; or YUI-compressor: java.util.MissingResourceException: Can't find bundle for base name org.mozilla.javascript.resources.Messages, locale de_AT how do you minify your code?any idea how to get this to work? thx in advance! tidelake 1 Link to comment Share on other sites More sharing options...
vulvulune Posted January 22, 2015 Share Posted January 22, 2015 The code is minified with the node package "grunt-contrib-uglify" (https://github.com/gruntjs/grunt-contrib-uglify) It uses internally uglifyjs (https://github.com/mishoo/UglifyJS2) Link to comment Share on other sites More sharing options...
stupot Posted January 22, 2015 Share Posted January 22, 2015 The default input language level in Closure Compile is ECMAScript3, which considers 'static' to be a reserved keyword - you should have seen some warning text to that effect. 'static' is reserved in ECMAScript2/3, but allowed in ECMAScript5 if not in strict mode. Adding something like this to your CC commandline parameters should sort it (unless in strict mode): --language_in ES5 Link to comment Share on other sites More sharing options...
chg Posted January 23, 2015 Share Posted January 23, 2015 The default input language level in Closure Compile is ECMAScript3, which considers 'static' to be a reserved keyword - you should have seen some warning text to that effect. 'static' is reserved in ECMAScript2/3, but allowed in ECMAScript5 if not in strict mode. Adding something like this to your CC commandline parameters should sort it (unless in strict mode): --language_in ES5Is this really better than suggesting he rename the variable? It shouldn't be that hard to rename it to avoid the reserved word and stay within strict mode. EDIT: Just to be clear, my vote is to rename the variable so it doesn't use the reserved word. Link to comment Share on other sites More sharing options...
valueerror Posted January 23, 2015 Author Share Posted January 23, 2015 Is this really better than suggesting he rename the variable? It shouldn't be that hard to rename it to avoid the reserved word and stay within strict mode.EDIT: Just to be clear, my vote is to rename the variable so it doesn't use the reserved word. you know what static is for? it's a phaser thing to set the body to a "do not move" state.. i have no hand on the naming of this property... thx for all your suggestions ... i'm going to try that Link to comment Share on other sites More sharing options...
valueerror Posted January 23, 2015 Author Share Posted January 23, 2015 so this is working now..thx!not really obfuscating though.. and the interesting thing about --compilation_level ADVANCED_OPTIMIZATIONS is that it actually renames the phaser functions which leads to errors but it works with SIMPLE_OPTIMIZATIONS Link to comment Share on other sites More sharing options...
stupot Posted January 23, 2015 Share Posted January 23, 2015 chg, yes 'static' is being used in Phaser as a property name, so renaming this would help although it would break compatibility for some users code, despite being a minor mod. Changing this does get my vote though. The fix I suggested allows the issue to be circumvented right now by anyone and without the need to edit Phaser source. valueerror, the closure compiler is a powerful beast, just switching on ADVANCED_OPTIMIZATIONS will usually lead to problems, you will learn that you either need to modify your source or feed CC with extra information to override it's default assumptions and stop it doing such a good job at optimisation. It be done though, I have CC fully optimising the Phaser lib and game code, the CC code is 23% smaller than the best UglifyJS could do and more obfuscated. Link to comment Share on other sites More sharing options...
amadeus Posted January 27, 2015 Share Posted January 27, 2015 You could also probably do the following to prevent the error: finishline.body['static'] = true; Link to comment Share on other sites More sharing options...
Partsu Posted January 27, 2015 Share Posted January 27, 2015 Another way would be to use:finishline.body.dynamic = false;On P2 this is the opposite of static. tidelake 1 Link to comment Share on other sites More sharing options...
Recommended Posts