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: http://www.npmjs.com/package/openfl
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 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" />
Thanks. After doing the npm install, I don’t get the “haxe-split” error and it seems to be doing something, but the output looks the same (no splitting). Here is the output:
$ openfl test html5 -Dcanvas -final
WARNING: Unexpected WhileStatement, at character 1332854
WARNING: Unexpected WhileStatement, at character 1333076
WARNING: Unexpected WhileStatement, at character 1333200
Parsed in: 436ms
Stats: 401 types, 4307 references
AST processed in: 158ms
Graph processed in: 6ms
Total process: 647ms
If I understand the library, that’s working. Now you use wrap code that should be split in Bundle.load (if I remember the API correctly) and the haxe-split tool will figure out what code can be split into what files
haxe-modular splits code upon request, but does not specifically separate OpenFL into a separate module. We do do that for our NPM releases, though
splitting is “on demand”, so read the documentation to create your split points,
OpenFl has/had a few incompatibilities in the generated code which hopefully are fixed in very recent releases; the “Unexpected WhileStatement” is an indication of that.
While I believe Lime has been fixed, OpenFl has still incompatible code (VectorData.__init__), and essentially the Stage3D API depends on it. So you can’t split a project using Starling for instance yet.