A template / starting point for a Haxe library that compiles to multiple targets and is published to both haxelib and npm. Clone it, rename, and replace the example code.
| Target | Output | Status |
|---|---|---|
| JS (CommonJS) | dist/js/cjs/index.cjs |
on by default |
JS (ES module + .d.ts) |
dist/js/esm/index.js |
on by default |
| C# (DLL) | dist/cs/dropecho.lib_example |
on by default |
| Python | dist/python/lib_example.py |
commented in build.hxml |
| Godot GDScript | dist/gdscript/ |
commented in build.hxml |
| API docs (dox XML) | artifacts/docs.xml |
commented in build.hxml |
npm install # fetch pinned Haxe + libs via lix (runs `lix download`)
npm run build # build the enabled targets (haxe build.hxml)
npm test # run the utest suite via dropecho.testing (lix dropecho.testing)
npm run clean # remove dist/ and artifacts/- Dependencies are managed by lix (a
devDependency, so no global install is needed): the Haxe version is pinned in.haxercand each lib inhaxe_libraries/.npm installinstalls lix, then runslix downloadto materialize them. - Build options are split into shared settings (top of
build.hxml) and one hxml per target undertargets/. Enable a target by uncommenting its--next targets/<name>.hxmlpair. - Tests are auto-discovered: every
test/**/*Tests.hxclass thatextends utest.Testis registered bydropecho.testing— there is no test main to maintain.
- Rename the package in
haxelib.json,package.json, and.releaserc.json. - Move/rename
src/dropecho/lib_example/to your own package and update the@:exposenames. - Set
root_packagein.dropecho.testing.jsonto your library's package. - Adjust output paths and enabled targets in
build.hxml+targets/*.hxml. - Replace the example sources and
*Tests.hx; refresh this README andLICENSE.md.
Pin any target's extra dependencies with lix (e.g. lix install haxelib:genes for the ESM
build, hxcs for C#, gdscript for GDScript) — it writes the lock to haxe_libraries/.
The CommonJS and ESM builds are wired up through package.json exports, so the package
works for both require and import. The ESM build also emits .d.ts typings via genes.
Releases are automated with semantic-release (see .releaserc.json): commits drive the
version bump, and the package is published to npm and haxelib with a generated changelog.
MIT