News for hackers. Stuff that matters.
Re:Jest not recommended to be used in Node.js due to instanc... by strogonoff on Saturday July 01, 2023 @01:16AM (#36546851)
It’s often cheaper to couple things tightly. Abstractions and interfaces have costs. However, they also have benefits. Perhaps React and Preact is one such example.

React is a tiny fully agnostic library that does components, props, hooks and all that jazz. You can use it anywhere, from DOM to CLI. To tie it to DOM, a separate library exists—named, unimaginatively, ReactDOM—and that’s where the 100KB heft comes in.

Preact is the opposite: smaller, but coupled to DOM. The architecture probably doesn’t facilitate cool stuff like render components to embedded LCD[0], and even to do SSR you would have to add extra libraries.

[0] https://github.com/doodlewind/react-ssd1306/blob/master/docs...

Re:Jest not recommended to be used in Node.js due to instanc... by acemarke on Saturday July 01, 2023 @01:37AM (#36546979)
It's somewhere in between.

React as a lib and architecture _is_ platform-agnostic. The core logic is defined in the `react-reconciler` package. It contains all the implementation of rendering components, diffing trees, managing state, and running effects, as well as all the "Suspense" implementation.

However, the way `react-reconciler` works is that it's built _into_ each platform-specific renderer implementation. So, the size of `react-dom` is actually the size of `react-reconciler` + all the DOM-specific behavior.

A quick check of https://bundlejs.com/?q=react-reconciler suggests it's about 100K minified. https://bundlejs.com/?q=react-dom is 138K, so that tells me that the DOM-specific logic is 38K.