ml-in-barcelona / jsoo-react

js_of_ocaml bindings for ReactJS. Based on ReasonReact.
https://ml-in-barcelona.github.io/jsoo-react
MIT License
138 stars 19 forks source link

Make React.Dom.Style.make more bundle size friendly #112

Closed jchavarri closed 2 years ago

jchavarri commented 2 years ago

Right now, every call to React.Dom.Style.make is compiled to a bunch of zeros on unused optional arguments.

This leads quickly to larger bundle sizes, e.g. for 7 usages of this function in some real world project, a prod bundle increases by ~17KB.

We should provide an API where the style properties are passed in a list, so unused ones don't lead into bundle costs.

e.g. like @davesnx does in jsoo-css:

  let box =
    React.Dom.Style.make([|
      color("333"),
      backgroundColor("C0FFEE"),
      padding("45px"),
      borderRadius("8px"),
      fontSize("22px"),
      fontWeight("bold"),
    |]);

I don't think we need type safety on each prop type, for a first version.