This issue is intended to track some ideas I have for reducing the size of the code generated for reason-js. These are ideas that are certainly generally useful, but that affect reason-js more severely due to its heavy use of implementation inheritance. Hopefully some of these are fairly low-hanging fruit.
Allow Js.boolean in bs.as. Removing the Js.boolean -> bool wrappers of just a few esoteric function high up in the inheritance hierarchy removed 30% of the (unminified) code (see this commit). Example: Generated - Source
Impl functors consisting only of externals still causes some unnecessary code to be generated. Example: Generated - Source
Autoconversion of bool and option to Js.boolean and Js.null etc. for arguments would remove a lot of wrappers. Example: Generated - Source
A lot of the remaining code is conversion from variants to their string representations. Example: Generated - Source
hi @glennsl for case 2, any reasonable bundler will remove such code
Thanks for the tip!
cc @chenglou ^
1,3 is addressed, please create a separate issue for item 4 if you think it is important
Most helpful comment
1,3 is addressed, please create a separate issue for item 4 if you think it is important