In addition to surrounding individual pieces of code with compile-time checks, it is possible to provide completely separate target-specific module alternatives to the compiler. This feature works as follows:
<Module>.hx
, it then checks the containing directory for a file called <Module>.<target>.hx
, where <target>
is the name of the current target.As an example, we can have the following directory structure:
/somepackage/Example.hx /somepackage/Example.js.hx /Main.hx
In Main.hx
we can use somepackage.Example
module. This module is defined in the file somepackage/Example.hx
. However, if we compile for JavaScript, the module is instead defined in the file somepackage/Example.js.hx
.