haxegon
haxegon copied to clipboard
HTML5 doesn't load static Main classes
Getting a weird bug right now where HTML5 won't run static Scene classes. This is super weird and new! Will look into it after 7drl.
OK! As a workaround, it looks like things will behave as expected if you just put a blank constructor in your class. I guess I must have broken this when changing from new to init as the startup function.
I'm working around it for now; will fix it next week.
from @randomnine :
if you're trying to include something from a package, you add
<haxeflag name="--macro include('package')" />
which would force it to include class in "package". eg package.Main
Oh, weird!
<haxeflag name="--macro include('package')" />
Doesn't fix it - in fact, the generated .js file DOES include the static function from Main - it's just that Scene doesn't see them.
Hmm, ok, not sure what's going on here right now. Gonna leave it for a while.
It doesn't seem to be a dce problem - the classes are in the .js file, and disabling dce doesn't change anything.
Also, I put together a little test haxe project, and it's not happening there. So... I'm kinda stumped! I'll try again later!
Ok, this test in Scene.hx:
trace(Type.getClass(maininstance) == null);
On html, this is true (unless the class has a "new" function). It's false on all other targets. This is why things are going wrong for haxegon.
If I can make a test case for this, then perhaps I can submit a bug to the haxe project, and have it fixed in a later version of the compiler.
Much better, though, would to be figure out a workaround...