COMMUNITY

How to expose std classes to js?

Hi,
I use @:expose to expose classes from my lib and used in external javascript .
I also need some Haxe std classes - Bytes.ofHex and Base64 class , but I do not have access to them.
How can I expose those classes ?

Could you extend the class then expose that?

You can add --macro addMetadata('@:expose', 'Std') (or whatever class you want to expose instead) to your hxml. You can also use addGlobalMetadata, if you want to expose everything. For maximum control, you can use Compiler.onGenerate to mark all the classes that interest you.

3 Likes

Thank you.
It works with --macro addMetadata('@:expose', 'haxe.io.Bytes') and --macro addMetadata('@:expose', 'haxe.crypto.Base64')