COMMUNITY

Add import to class through macro

macro

(Remco Huijser) #1

We are trying to add an import definition to a class with a build macro, but cannot find a way to do this… Anyone got experience with this?


(Dmitry Hryppa) #2

Basically, imports can be contained by module (your .hx file), not a class.
There is an API for module definition which gives you a way to add imports into it:
https://api.haxe.org/haxe/macro/Context.html#defineModule

And I’m not sure if you can add it into an already existing module. But I’m may be wrong.


(Remco Huijser) #3

Very nice: will check it out!