COMMUNITY

Compiler plugin adapted for JS target? (async, await)

Right now, I’m doing almost nothing but JS development with Haxe, and in spite that haxelibs like jsasync (1.2.1) and hxasync (1.1.0) do a great job for macrowise making it possible to use async and await, they are workarounds with limitations.

Re-saw Aleksandr’s “Plugins for the Haxe Compiler” the other day (https://www.youtube.com/watch?v=4Iy1_HcMuIk), wich got me thinking…
Would it be possible - through a compiler plugin - to extend the compiler JS target to handle the async/await keywords 1:1 (or almost) to how they work in native JS?

This would of course not work for other targets, and it would of course require me to build my own compiler. But that would be a cheap price, I think. And of course, it will soon be redundant, replaced by the native fancy cross-target Haxe concurrency solution we’re all waiting for… :slight_smile:

In the meantime, would a JS-specific compiler like this plugin be possible?

(It wouldn’t hurt if it at the same time could cope with object destructuring and some other nice modern js features :-), but async/await for sure are at the top of my list and would be good enough).

Plugins don’t allow to alter Haxe syntax or add new keywords.

Ah, I see. Thanks, Aleksandr!