aantron / promise

Light and type-safe binding to JS promises
MIT License
340 stars 24 forks source link

Reduce compiled size again #57

Closed aantron closed 4 years ago

aantron commented 4 years ago

See https://github.com/aantron/promise/issues/54#issuecomment-646112858. It is currently a bit under 4K over 1K (thanks @cknitt), up from an earlier ~950 bytes, but, per the linked comment, there is likely a lot of the new stuff that can be easily reduced.

cknitt commented 4 years ago

Also, the Promise.allOk code uses the Array module from the OCaml stdlib, so that the compiled code imports both

var Belt_Array = require("bs-platform/lib/js/belt_Array.js");
var Caml_array = require("bs-platform/lib/js/caml_array.js");

I think it would be better to use Belt everywhere.

aantron commented 4 years ago

Thanks, good catch. I chose Array for this initial version so I could write the same code for native and JS in limited time :) I'll solve this issue in a week or two and do a follow-on release.

aantron commented 4 years ago

After #58 by @cknitt replaced Array fully by Belt.Array, the compiled size is 1184 bytes

aantron commented 4 years ago

The above commit further reduced the compiled size, to 1099 bytes. This version of the library is now in npm as reason-promise@1.1.1.

As an interesting factoid, when it comes to the source size, 60% of the published npm package is the library README :)