ai / size-limit

Calculate the real cost to run your JS app or lib to keep good performance. Show error in pull request if the cost exceeds the limit.
MIT License
6.54k stars 1.82k forks source link

React should be peer dependency #331

Closed ad1992 closed 1 year ago

ad1992 commented 1 year ago

In the package @size-limit/time, react @17.x is a dependency which leads to installing multiple versions in host and increasing bundle size as well.

https://github.com/ai/size-limit/blob/main/packages/time/package.json#L24

It should be instead a peer dependency where 17.x / 18.x should be allowed whichever host is using.

ai commented 1 year ago

@size-limit/time is not using on client-side. It is server-side only package.

Are you sure it leads to increasing bundle size? Can you show some project with this issue?

ad1992 commented 1 year ago

@size-limit/time is not using on client-side. It is server-side only package.

Are you sure it leads to increasing bundle size? Can you show some project with this issue?

Since size-limit a dev dependency so bundle size eventually won't matter but due to multiple versions of react the host build can break if they are on React 18 specially thats what is happening right now https://github.com/excalidraw/excalidraw/issues/6801

ai commented 1 year ago

Hm. The problem is that we can’t use host’s version.

We are using React sources to estimate to CPU power of CI by parsing these sources. React 18 and React 17 has a different size and the result will be different.

But we can switch from React to some another library. Do you know some big library without dependencies?

ad1992 commented 1 year ago

parsing these sources

In that case instead of using the npm package for react, you can keep a local copy of its react.production.min.js ? or even use the unpkg link ? That way host don't have to install react

ai commented 1 year ago

Hm, interesting idea. Do you want to send PR to keep your name in the project’s history?

ad1992 commented 1 year ago

Sure I will raise a PR shortly

ad1992 commented 1 year ago

@ai had been busy so couldn't raise the PR, I have opened a PR and this seems to work fine, let me know