I think defining exactly what the role of the 'package manager' is (vs the build tool) must come first.
Package manager is a tool that both downloads, and resolves package and its dependencies. It does not have to be part of a build tool. I feel that conflating both the build step, and the dependency resolution step into one tool will not work in the haxe ecosystem (since haxe is a source->source compiler, and each output target has its own canonical build tools). Therefore, to make a haxe package manager work for all targets, it must set about defining a format for defining dependencies of the current project being compiled (which is then in turn used by other projects). This format must include a specification for a way to retrieve its dependencies for each target. I think extending haxelib.json
to include more data, including the retrieval mechanism for externally compiled libaries, is the way to go.
haxelib.json
:
{
"dependencies": {
"haxe" :[
{ name: "pure-haxe-lib-1", version: "3.4.64"},
{ name: "my-custom-lib", location:"my-custom-lib/src"}
],
"java" : [
{ name: "some-java-lib-1", location: "libs/java/some-java-lib-1.jar"},
{ name: "some-java-lib-2", location: "libs/java/some-java-lib-2.jar"},
],
"js" : [
{ name: "some-js-lib-1", location: "libs/node_modules/some-js-lib-1", hxml:"-D 'some_stuff'"},
{ name: "some-js-lib-2", location: "libs/node_modules/some-js-lib-2"},
]
}
}
}
This dependency will be hand written by the author of the haxe library/project. It is then up to the author of the project to work out how to put the required external dependency files in to the locations described by this file. haxelib.exe
will parse this dependency description, and in the case of pure haxe dependencies, resolve transitives, and output a hxml
file required to compile the current project.
I am deliberately not integrating any existing external dependency tool knowledge into the haxe package management, because any target output language is subject to change, and haxe is not able to continuously keep up. The authors of libraries need to figure out the best way to integrate it into the target language's ecosystem.