News for hackers. Stuff that matters.
Re:Jest not recommended to be used in Node.js due to instanc... by Uehreka on Friday June 30, 2023 @11:39PM (#36546239)
OK, hold up, I’ve been hearing this line forever and I’m here to hold it to account:

> the API-compatible Preact is something like 7KB

Something is up here. Either Preact is not in fact API-compatible (in which case people should stop saying this), or the React devs are dummies who have never thought of Preact’s architecture or looked at its open source code (I rank this unlikely) or there’s somehow some other catch that no one talks about.

Which is it? Why doesn’t React just use Preact’s architecture if it’s so lightweight? What is Preact actually giving up?

Re:Jest not recommended to be used in Node.js due to instanc... by Inviz on Friday June 30, 2023 @11:48PM (#36546308)
It's fully api compatible pre-fiber. in fact it has more apis in some regards.
Re:Jest not recommended to be used in Node.js due to instanc... by tcpipchip on Sunday July 09, 2023 @06:16PM (#36659528)
Hi Did have success on littlefs on stm32 ? On arduino ? Please, contact me [email protected] PS: sorry if I post here
Re:Jest not recommended to be used in Node.js due to instanc... by Inviz on Thursday July 13, 2023 @10:35AM (#36709805)
I did have some success with it. I used their generic config way to hook up fro block writing/erasing and implemented those parts in the os i was writing. However one thing I was not a fan of is that its IO is synchronous, so you have to use some sort of coroutines/multitasking unless you're ok with blocking
Re:Jest not recommended to be used in Node.js due to instanc... by gedy on Saturday July 01, 2023 @12:04AM (#36546445)
From memory, Preact doesn't use synthetic events system like React and its runtime is much smaller. It can't be used generically like React can in mobile (React Native) or similar though because of this
Re:Jest not recommended to be used in Node.js due to instanc... by afavour on Saturday July 01, 2023 @12:15AM (#36546515)
There are definitely differences here and there. One I can remember from a year or so ago is that Preact deprecated support for string refs while React still supports them (though the docs point out they intend to deprecate IIRC).

Honestly to my mind the biggest thing is that bundle size just isn’t a priority for the React team. A sibling comment pointed out that React does a lot to correctly handle SVGs. Good to have, obviously, but what percentage of React users are making interactive SVGs? Probably not a whole lot. If they wanted to the React folks could break that out into a react-svg module or something and save some KB. But they don’t want to.

To my mind React these days is the enterprise software of the frontend. It’s big, it’s bulky, but it does absolutely everything with a minimum of fuss. They have a one size fits all approach and they’re not willing to deviate from it.

Re:Jest not recommended to be used in Node.js due to instanc... by fathyb on Saturday July 01, 2023 @12:26AM (#36546585)
> what percentage of React users are making interactive SVGs

Every single app I worked on for the past 5 years did. `mui` icons are SVG for example, and it's common practice to embed SVG as components to avoid the HTTP requests overhead and allow for theming through props.

Re:Jest not recommended to be used in Node.js due to instanc... by josephg on Saturday July 01, 2023 @04:50AM (#36548145)
Most people who embed svgs aren’t looking to make them interactive though. I think I’ve attached event handlers to internal elements in an svg maybe once in my entire career.
Re:Jest not recommended to be used in Node.js due to instanc... by pcthrowaway on Saturday July 01, 2023 @06:08AM (#36548514)
Things like the sparkline charts on npmjs (e.g. https://www.npmjs.com/package/npm ) are interactive SVGs. I think they're pretty common for data visualizations of all kinds
Re:Jest not recommended to be used in Node.js due to instanc... by josephg on Saturday July 01, 2023 @08:42AM (#36549499)
Sure, but data visualisations make up a tiny percentage of websites.
Re:Jest not recommended to be used in Node.js due to instanc... by afavour on Saturday July 01, 2023 @10:47AM (#36550694)
That’s a great example of what I’m talking about: it would be the perfect place to bring in a react-svg module. Vast majority of sites don’t use sparkline so the SVG stuff is unused.
Re:Jest not recommended to be used in Node.js due to instanc... by afavour on Saturday July 01, 2023 @09:12AM (#36549719)
That’s not what I’m talking about though: those aren’t interactive. You could dangerouslySetInnerHTML with them (arguably you should, it’s a waste of VDOM otherwise) and they’d be just fine.
Re:Jest not recommended to be used in Node.js due to instanc... by orangepanda on Saturday July 01, 2023 @02:46AM (#36547387)
Preact takes the King Bumi approach to API compatibility - by sometimes doing nothing.

The syntax may be compatible, but the semantics are not. For example, it doesn’t support react's concurrency features; transitions are just empty wrappers.