gcanti / prop-types-ts

Alternative syntax for prop types providing both static and runtime type safety, powered by io-ts
MIT License
171 stars 5 forks source link

Bundle size jump #22

Open ifiokjr opened 4 years ago

ifiokjr commented 4 years ago

Since the update (#20) to the new version the bundle size has increased from 7.5 kB -> 11.1 kB. There may be nothing that can be done, but I was wondering how to address it since the default prop-types library comes in at 532 B.

I'm thinking it may be to do with the way their index file is structured to use shims when in production.

image

gcanti commented 4 years ago

This is weird, in their view io-ts went from 7.9kB to 4.7kB by switching to fp-ts@2.x, where the jump in prop-types-ts comes from?

ifiokjr commented 4 years ago

I think I see why.

Because io-ts switched to using fp-ts as a peer dependency it's bundle size dropped and because I added fp-ts as a direct dependency while upgrading the package file size has increased.

gcanti commented 4 years ago

Here's the numbers from https://bundlephobia.com

library minified
fp-ts@2.4.0 123.8
io-ts@2.0.4 18.8
prop-types-ts@0.7.0 55.1

But then in the Composition section (from https://bundlephobia.com/result?p=prop-types-ts@0.7.0), says

io-ts: ~35.05 (io-ts code + fp-ts/lib/Either?) fp-ts: ~17.14 (fp-ts/lib/Either module?) self: ~2.92

Does it count the fp-ts/lib/Either module twice?

io-ts: ~35.05 = io-ts code: ~18.8 + fp-ts/lib/Either: ~17.14