Okay, I just used Haxe + Haxelib successfully with the NPM-based approach. Here’s how I did it:
mkdir HaxelibTest
cd HaxelibTest
yo openfl
Select “Haxe” from the language drop-down.
In order to use the included copy of Haxelib, you have to remove the local Haxe 3.4.4 and change it to Haxe 3.2.1. With some work, the “NPM Haxe” project should be able to work for 3.4.4 or newer as well, but I guess that isn’t fully working (at time of writing here). I edited “package.json” and changed “haxe” to “3.2.1”, removed “node_modules/haxe” (or you could remove the whole directory) and run npm install
in the project directory again. While you have “package.json” open, you can also add another script:
"postinstall": "haxelib --always install build.hxml",
This will run haxelib install
for any referenced -lib
values in your “build.hxml” when you run npm install
. For my test, I added -lib actuate
to my “build.hxml”, and ran npm install
again.
Here was my quick sample code:
import openfl.display.Sprite;
import openfl.display.Stage;
import motion.easing.Linear;
import motion.Actuate;
class App extends Sprite {
public function new () {
super ();
var sprite = new Sprite ();
sprite.graphics.beginFill (0xFF0000);
sprite.graphics.drawRect (0, 0, 100, 100);
addChild (sprite);
Actuate.tween (sprite, 10, { x: 100 }).ease (Linear.easeNone);
}
static function main () {
var stage = new Stage (550, 400, 0xFFFFFF, App);
js.Browser.document.body.appendChild (stage.element);
}
}
npm start -s
and it was working properly.
If you do not want (or need) to use a local copy of Haxe, you can npm uninstall --save-dev haxe
on your project (and remove the “config” for it if you prefer) and use -lib
in your build.hxml just the same. You’ll install and manage haxelib globally, like normal. Either way, I have Webpack + OpenFL + regular Haxe libraries working. The important caveat is that this approach is OpenFL without any Lime APIs, which some libraries may use