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: http://www.npmjs.com/package/openfl
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:
I’ve loaded the following before my project module:
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
Bundling…
Graph processed in: 6ms
Emit /Users/blah/Documents/devel/haxe/projects/wechat/Export/html5/bin/GemMiner.js
Write /Users/blah/Documents/devel/haxe/projects/wechat/Export/html5/bin/GemMiner.js
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.
@elsassph I know that Vector.hx is a bit complex, especially with the defines. The __init__ is actually only when building for NPM builds of OpenFL, so that shouldn’t conflict with haxe-modular