Hook into default JavaScript generator?

47 views
Skip to first unread message

Leff Ivanov

unread,
Apr 25, 2016, 7:44:23 AM4/25/16
to Haxe
I know that Haxe has a very nice macro system, but I want to apply it to my practical task. Is it possible to hook into default JavaScript code generator and change it a little bit? What I wan't to do is to be able to minify/obfuscate my self-contained JavaScript application written in Haxe. For example I want all of my class and function names to be minified to minimal strings like "a", "A" and etc. Also I want to remove all unnececery whitespace from the generated JavaScript code. And perform some other modifications on the generated JavaScript code. Can this task be solved via Haxe's macros?

Juraj Kirchheim

unread,
Apr 25, 2016, 7:52:02 AM4/25/16
to haxe...@googlegroups.com
Yes and no. The simplest way to do it is to use Context.onAfterGenerate to process the generated JavaScript.

FWIW, this library does such a thing already (provided you set -D closure_advanced): http://lib.haxe.org/p/closure/

Best,
Juraj

On Mon, Apr 25, 2016 at 1:44 PM, Leff Ivanov <droid...@gmail.com> wrote:
I know that Haxe has a very nice macro system, but I want to apply it to my practical task. Is it possible to hook into default JavaScript code generator and change it a little bit? What I wan't to do is to be able to minify/obfuscate my self-contained JavaScript application written in Haxe. For example I want all of my class and function names to be minified to minimal strings like "a", "A" and etc. Also I want to remove all unnececery whitespace from the generated JavaScript code. And perform some other modifications on the generated JavaScript code. Can this task be solved via Haxe's macros?

--
To post to this group haxe...@googlegroups.com
http://groups.google.com/group/haxelang?hl=en
---
You received this message because you are subscribed to the Google Groups "Haxe" group.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages