编译没有 Main 的 Haxe 库 class

Compiling a Haxe library without a Main class

我正在用 Haxe 编写一个不公开 "Main" class 的库。 相反,它只包含 typedefs 和 classes,它们旨在用于 在其他编译的应用程序中,包括这个库。

如果我尝试在没有 -main 选项的情况下进行编译,我会收到以下错误:

Haxe Compiler 3.2.1 - (C)2005-2015 Haxe Foundation
 Usage : haxe -main <class> [-swf|-js|-neko|-php|-cpp|-as3] <output> [options]

Haxe 编译器是否会阻止您编译没有入口点的库?


您可以在没有 main 的情况下使用类似下面的内容进行编译 build.hxml:

-cp src 

# add the package(s) that you want to include the following way: 
--macro "include('package1.foo')"
--macro "include('package2.bar.test.buz')"
...

-js bin/index.js

希望对您有所帮助!