I am trying to compile a Haxe class without defining an entry point by using a build hxml
file.
My folder structure looks like the following:
root
|
___src
|___Test.hx
|
___build.hxml
Test.hx
has the following contents:
package foo;
class BarLib
{
public function new() {}
public function test() {
return "Hello from BarLib!";
}
}
build.hxml
looks like this:
-cp src
--macro "include('foo')"
-js test.js
I then run haxe build.hxml
from the root folder which creates the file test.js
, but its contents is pretty much empty:
// Generated by Haxe 3.3.0
(function () { "use strict";
})();
It seems not to be able to locate the package foo
.
What am I doing wrong?
You declare Test.hx
to be part of the foo
package, however, it's placed in a folder named src
. If you move it to src/foo
, Haxe produces the following output:
// Generated by Haxe 3.3.0
(function () { "use strict";
var foo_BarLib = function() {
};
foo_BarLib.prototype = {
test: function() {
return "Hello from BarLib!";
}
};
})();
It's also a bit unusual to have a file named Test.hx
that doesn't actually define a type named Test
. BarLib.hx
might be a better name.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With