3 ms·
It’s very possible and easy to get everything working the same way on the client and server but I agree the whole import vs require support is frustrating. I s
by bern4444 5y ago
It’s very possible and easy to get everything working the same way on the client and server but I agree the whole import vs require support is frustrating.
I set my stuff up to always use import syntax over require now which is what typescript works best with.
Of course the APIs in node vs DOM are very different. They do very different things but the benefit comes from having the same language support, syntax, type system, and methods. Types can be shared across the client and server so changes on one side are immediately detected on the other. It is annoying there’s no native fetch in Node but there’s a east npm package to support isomorphic fetch (node-fetch)
JSX is “just js” in that they are compiled down to simple function calls (React.createElement), there’s just a nicer syntax but there are systems (hyperscript I think) that just export functions like h1(), div() etc that do the same thing.