OpenFL separate module?


As currently I am compiling openFL project to js, I have both openfl, lime and my source code into one file.
How would I compile my source code into a separate js file? what’s the command line?

Also, is there a pre-compiled openfl module for latest release to download and use? Do I need to use lime separate module too?


There is a -Dmodular define, which should break up our HTML5 output into additional files. However, we are also working on a NPM-based version of OpenFL, which supports either distinct CommonJS modules, or also generates a single “openfl.js” distribution file that can be used. Work on this is continuing, you can read more here:


Technically, would it be possible to get only the dependencies that my project needs in order to run? thus, avoiding those framework parts that my project does not use, and thus, saving more bytes?

Also, is there an example project which is compiled with -Dmodular? as I tried to do so, but I’ve noticed that the look of components got different, ex:

44 AM

I’ve loaded the following before my project module:

    %script{:src => "#{lab_info.url}lib/pako.min.js"}
    %script{:src => "#{lab_info.url}lib/FileSaver.min.js"}
    %script{:src => "#{lab_info.url}lib/howler.min.js"}
    %script{:src => "#{lab_info.url}lib/haxe.js"}
    %script{:src => "#{lab_info.url}lib/lime.js"}
    %script{:src => "#{lab_info.url}lib/openfl.js"}


The NPM approach does use only the parts that you use, but doesn’t have Lime tool support. The -Dmodular approach should separate into different files (and shouldn’t change the behavior as far as I know) but doesn’t know what features you used, so it includes all features


Hello, if your goal is to load parts of your application on-demand, you may want to look into the, confusingly similarly named, Haxe Modular project.

I just registered to the new forum so I’m not sure I can share the URL :wink: it’s “haxe-modular” on Github, under my account “elsassph”. A fix in OpenFl was recently merged to better support this JS code splitting approach - maybe @singmajesty can confirm whether it was released.


There is a conflict between OpenFL’s modular option and haxe-modular’s haxelib version which is also named modular :

When you define a library in your project.xml with the name modular by using this syntax : <haxelib name="modular" />, the resulting .hxml will include a -D modular=0.8.0 line. This will then trigger openfl’s -D modular, which is something you don’t want.

To solve this, you have to download haxe-modular into some directory, and then install it with haxelib dev haxe-modular path/to/modular. Then you can include the library in your project.xml with <haxelib name="haxe-modular" />

PS : The link to haxe-modular is