Jump to content

can't minify phaser code because of the word "static"


valueerror
 Share

Recommended Posts

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!
Link to comment
Share on other sites

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

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

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.

Link to comment
Share on other sites

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

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

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...