Open elsassph opened 6 years ago
I would be fine with that from an API point of view, but it might be a little tricky to implement because the compiler doesn't hold the output as a plain string in order to avoid OCaml memory limitation problems.
Oh so output is direct to file? maybe we'd need a stream, which could be either directly to file or to memory. Effectively we need to support situations where the JS output is tens of MBs.
It uses some rope-based buffer. At least on Js. So maybe it's not actually a problem.
How about fileName:String->haxe.io.Output
for the callback? Then you can pull all kinds of fancy tricks, like open a process and return its stdout or what not.
One recurring discussion is to add an API for the Haxe compiler to function in memory - this is desirable for tooling.
My last idea, to permit it without having any hard-coded protocol in the compiler is to offer macros to register a callback to emit files:
Register a callback receiving:
filePath
: path of the file to writecontent
: body of the file to writeNote: it's probably naïve and would require more options to emit binary files.
Using such API, a macro could freely: