3 ms·
Yeah Preact provides you with most of the benefits of React without the massive bundle size of react-dom (react-dom is roughly 130kb minified, whereas Preact is
by throwitaway1123 3y ago
Yeah Preact provides you with most of the benefits of React without the massive bundle size of react-dom (react-dom is roughly 130kb minified, whereas Preact is about 11kb minified) [1][2].
The author even mentions Solid, so presumably he's aware that there are other frameworks utilizing JSX.
[1] https://bundlephobia.com/package/react-dom@18.2.0 https://bundlephobia.com/package/react-dom@18.2.0
[2] https://bundlephobia.com/package/preact@10.20.0 https://bundlephobia.com/package/preact@10.20.0
- WorldMaker 3y agoI always forget to compare to react-dom, rather than react. Easy to forget that react-dom is a peer-dependency rather than a direct dependency. My JSX-based but not React framework has one large direct dependency (RxJS), but still comes in less than react-dom and comparable to preact: https://bundlephobia.com/package/butterfloat@1.4.0 https://bundlephobia.com/package/butterfloat@1.4.0 Similarly, I have to keep remembering that when trying to argue for web component embedding that it isn't competing with just lit, but generally lit and lit-html together: https://bundlephobia.com/package/lit@3.1.2 https://bundlephobia.com/package/lit@3.1.2 https://bundlephobia.com/package/lit-html@3.1.2 https://bundlephobia.com/package/lit-html@3.1.2 I wonder if bundlephobia needs more of "peer dependency" mode.
- throwitaway1123 3y agoIt's definitely easy to forget about peer dependencies, which is why I'll often just spin up a Vite project and examine the actual build output to be certain about bundle sizes. To be fair to React though, in any production Preact app you'll probably end up pulling in either Preact Hooks or Preact Signals, which will add a few kb (unless you're using class components), but Preact Hooks is still only 3.7kb [1]. In the case of lit, I think lit-html actually is a direct dependency of lit (unless I'm reading it wrong)? In the composition section at the bottom of lit's Bundlephobia page it says lit-hmtl makes up 46.1% of lit's bundle size. The one thing you do have to remember about lit though is that if you're server side rendering you'll also need the @webcomponents/template-shadowroot polyfill, and @lit-labs/ssr-client/lit-element-hydrate-support.js [2]. I agree that Bundlephobia needs a peer dependencies mode. It still might be tough to be exhaustive about these things because react-dom depends on react as a peer, but confusingly the reverse is not true, because even though almost everyone is using react with react-dom, you could technically render to a different target (e.g. Ink uses react to render terminal UIs). Bundlephobia would need to be aware of packages that are so commonly used together that they're de facto peer dependencies, even if they're not de jure peer dependencies. [1] https://unpkg.com/browse/preact@10.19.3/hooks/dist/ https://unpkg.com/browse/preact@10.19.3/hooks/dist/ [2] https://lit.dev/docs/ssr/client-usage/ https://lit.dev/docs/ssr/client-usage/