Rescript-compiler: Opportunities for reducing the code size of reason-js

Created on 21 Mar 2017  路  3Comments  路  Source: rescript-lang/rescript-compiler

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.

  1. 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

  2. Impl functors consisting only of externals still causes some unnecessary code to be generated. Example: Generated - Source

  3. Autoconversion of bool and option to Js.boolean and Js.null etc. for arguments would remove a lot of wrappers. Example: Generated - Source

  4. A lot of the remaining code is conversion from variants to their string representations. Example: Generated - Source

Most helpful comment

1,3 is addressed, please create a separate issue for item 4 if you think it is important

All 3 comments

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

Was this page helpful?
0 / 5 - 0 ratings

Related issues

bobzhang picture bobzhang  路  5Comments

andares picture andares  路  5Comments

alexfedoseev picture alexfedoseev  路  5Comments

chenglou picture chenglou  路  4Comments

cknitt picture cknitt  路  3Comments