storybookjs / storybook

Storybook is the industry standard workshop for building, documenting, and testing UI components in isolation
https://storybook.js.org
MIT License
84.06k stars 9.24k forks source link

Investigate replacing `sharp` with `image-dimensions` for detecting the size of AVIF and WebP #29195

Closed JReinhold closed 1 day ago

JReinhold commented 1 day ago

sharp is a pretty heavy dependency of the @storybook/nextjs framework, at 29 MB.

AFAIK it's only used to detect the size of AVIF images:

https://github.com/storybookjs/storybook/blob/0811ca8bd592dbee4eadb94f46fccadda21fe0bf/code/frameworks/nextjs/src/next-image-loader-stub.ts#L50-L63

Can we perhaps replace it with image-dimensions which is only 15 KB and supports AVIF too?

JReinhold commented 1 day ago

Closing because sharp is already depended on by next, so it will just reuse sharp from that dependency-chain as long as they have it installed there.