Have you ever tried to compile a large Haxe Project? When using the standard build processes it can take quite some time to compile large projects. Well, I have a solution to your issue to speed up your rapid development.
Haxe Compilation Server
In Haxe we can use the Haxe compilation server to create faster compilation times. The way we set up the server is by doing the command line command you see below.
As you can see above, the command sets up a Haxe server that’s waiting for you to compile your code on port 7010. Once you create that server, you can use your favorite file watcher. I currently use nodemon to run the compilation command on file change.
Here’s an example using Nodemon in my current project to compile my Haxe code.
As you can see above, we’re using Nodemon to compile the Haxe code. Let’s breakdown the flags in the command for understanding. The –watch is used to initiate file watching on the src directory in my project. The -e in the command is used to tell Nodemon which files to watch for changes before running the command that is following the –exec flag. Now, what this last section of the command will do, is run compilation and show you the compilation data in a table. But, you might be wondering how does this actually speed up compilation time? Let me explain.
How The Speed Up Works
The compilation server only compiles the files that have changed during compilation rather than everything over again. After the first time, you compile your project this way, it will dramatically speed up the time it takes to compile because the files that are not changing are cached(stored in memory on the server) to improve the overall compilation performance.
With that said, I hope this helps and have a good one! For more information on the compilation server, you can find it here.