JsUnHaXe - Javascript cleanup for Haxe
When developing flash games, you often need different architectural components: the game in flash, a server for save states and high scores, and maybe javascript for integrated flash-and-html user experience like status messages on the web page reflecting in-game events.
Haxe is a swiss toolkit language: write all your code in haxe and then compile to different platforms like neko or php (for the server), flash or javascript. Now I will consider the javascript target.
Haxe and multi-file javascript
When compiling to javascript, you often would like to separate functionality into a common core and smaller modules. However when compiling with Haxe, it will generate all the core data into the sub-modules too (well, this is not a precise description of what is happening, but let's stick with it for now).
Having a MyCore class and a MyCoreExtension1 class, after compiling with haxe -js my_core.js MyCore and haxe -js my_core_ext1.js MyCoreExtension1, both generated js files will contain definitions for MyCore.Fortunately it doesn't seem to be hard to decouple the modules from the core. I wrote a small python script that I call JsUnHaXe, which removes redundant entries from generated js files. Download and try it using python jsunhaxe.py out_dir my_core.js my_core_ext1.js. Note that sub-modules, sub-sub-modules, etc. can be passed, in this case the Kth output file will lack all entries beginning from the first and up to the K-1th input file.
Happy Haxing!
Comments
Comment by [ron], (URL) on 09.11.02. 00:48
Updated to JsUnHaXe v0.11, now the directory containing the javascript sources can be set as output dir too, so it will overwrite sources correctly.
Comment by [ron], (URL) on 09.11.02. 22:24
Updated to JsUnHaXe v0.1.2, fixed state machine bug and non-workdir js file processing.
