List.nth doesnt tree shake well


Been playing around with the std library trying to understand how much overhead using reason adds to my builds. Most simple reason files end up pretty small (under 3kb uncompressed).

I ran into one that’s surprisingly large.

Js.log(List.nth([1,2,3], 1));

With the best tree shaking I can muster, parcel build --experimental-scope-hoisting its coming in at 20kb.

(I ran this through prettier before putting in the gist)

Anyone know whats going on here?


Hi, Can you try Belt.List.length, in general, belt is optimzied for size


@bobzhang Yep that was it! dropped to. 1.8kb. I also discovered it seems to be a deficiency with with parcel’s tree shaking. I rebuilt the original source with rollup and it went down to 1kb.

parcel + belt