Glidias / haxevx

HaxeVX - Haxe-powered VueJS/Vuex development. Why? So you can write HTML application/interface templates in fully strict-typed-safe Haxe, while using haxevx as a seamless bridge to your existing Haxe codebases/classes, keeping the benefits of OO/encapsulation and cross-platform inter-operability within your Haxe codesbase itself.
21 stars 1 forks source link

add @:keep and @:keepSub in class components #4

Closed francescoagati closed 7 years ago

francescoagati commented 7 years ago

with the use of the dce (Dead Code Elimination) the fields in components are deleted. the solution to this problem is using keepsub https://haxe.org/manual/cr-dce.html

Glidias commented 7 years ago

Done and pushed to both Git and Haxelib tagged version ~0.6.0~ 0.6.1. Do test it out and see if you have any issues.

The approach was: Instead of using @:keepSub on base classes, , all classes running with buildComponent() (excluding the base boilerplate classes) now uses @:keep individually per specific class, automatically injected by the build macros. Same likewise for Vuex related build macros. Since, it's hooked on autoBuild, @:keep on all the classes will be added, without needing @:keepSub. This is actually good because it actually removes the boilerplate functions/fields in base class VComponent as well..something that i was figuring out, considering the use of proposed roadmap IComponentOf<..> interfaces as an alternative and @:vue declarations to skip the base class boilerplate codes being generated., With dce full being an option, the amount of boilerplate code added through VComponent is close to none... (if you didn't override the function, it won't get generated), so this means extending Base class implementation won't be too bloated anyway.....since whatever that doesn't get used in the base class, will be deleted off anyway. IComponentOf interfaces is thrown over to the YAGNI list for the roadmap, as I seem pretty happy with the base classes at the moment.

However, do note now that if you have unused functions/fields in your Specific Component classes and such, they'll still be included in, nevertheless, as @:keep is applied to the entire class. I currently have no option to opt out of this, though I doubt most users would wish to manage their dce manually per field So, make sure you clean up any unused code/functions directly for your Components/Actions/Mutators/Getters/Modules/ etc.