News for hackers. Stuff that matters.
Re:RawJS is a better way to call document.createElement() by jakelazaroff on Wednesday January 03, 2024 @11:21AM (#38855867)
Can someone explain these bullet points from the sample repo? [1] They seem contradictory, but maybe there's some esoteric definition of "builds" that I'm missing.

> - No bundler, no build system. Near-zero complexity.

> - TypeScript builds your app in milliseconds, even if your app gets huge.

[1] https://github.com/squaresapp/rawjs-sample

Re:RawJS is a better way to call document.createElement() by spoiler on Wednesday January 03, 2024 @12:43PM (#38857027)
I think they reference two different things

The first statement means you don't need a compiler (or larger build system) to use the library. With React/Vue/etc you need at least something like Babel (but usually also needs a bundler); which has become common lately in the web dev ecosystem. This is all just vanilla JS (or TS) you write; no need to transform JSX or some else.

I assume the second statement means there's not a lot of added type checking time burden for using the library, if you do decide to use TypeScript in your project (but don't have to). Not sure what this means specifically, but I might be something along the lines of it relying on simpler types or eager `any`s in internal types to short-circuit resolving/checking types.

Re:RawJS is a better way to call document.createElement() by chuckadams on Wednesday January 03, 2024 @01:00PM (#38857286)
> With React/Vue/etc you need at least something like Babel

VueJS works with just a CDN link and a script tag. Nothing serious actually uses this approach, and they stopped using it for examples, but it still works.

Re:RawJS is a better way to call document.createElement() by throwitaway1123 on Wednesday January 03, 2024 @05:46PM (#38860886)
> With React/Vue/etc you need at least something like Babel (but usually also needs a bundler); which has become common lately in the web dev ecosystem. This is all just vanilla JS (or TS) you write; no need to transform JSX or some else.

The TypeScript compiler has native support for JSX. You don't need Babel, you just have to add the '"jsx": "react"' line to your tsconfig file to enable it.

Re:RawJS is a better way to call document.createElement() by spoiler on Thursday January 04, 2024 @09:17AM (#38867247)
The TS compiler might produce something, but that's not usually enough in the context of a larger React application (eg, they often import non-ts files).
Re:RawJS is a better way to call document.createElement() by throwitaway1123 on Thursday January 04, 2024 @05:15PM (#38873046)
> The TS compiler might produce something

It'll produce calls to React.createElement provided with: the tag name, props, and children. That's all JSX is.

> but that's not usually enough in the context of a larger React application (eg, they often import non-ts files)

React and JSX don't require you to import non-ts files. If RawJS's nascent ecosystem picks up momentum, people might start importing non-ts files in RawJS projects (e.g. css modules). My point is that there's nothing special about the RawJS api that allows you to skip a build step, and conversely, there's nothing about React that requires Babel (assuming you're already using TypeScript).

Re:RawJS is a better way to call document.createElement() by Py_ on Wednesday January 03, 2024 @03:01PM (#38859047)
Repo author here. Sorry–maybe not the best choice of words.

By "no bundler, no build system", it kind of means "no webpack, rollup, gulp, etc".

I tend to think of TypeScript as a non-negotiable for any serious project (hopefully I don't get flamed for saying that), so using the build system that's baked into TypeScript means you don't have to rely on yet another tool to handle this.

Re:RawJS is a better way to call document.createElement() by jakelazaroff on Friday January 05, 2024 @01:33AM (#38876386)
I see. I don’t really agree with lumping everything else into “yet another tool”:

- The marginal cost of adding a second tool to your build step is generally lower than adding a build step in the first place

- Tools like esbuild give you both TypeScript compilation and bundling out of the box with zero extra dependencies, so you don’t actually need to add an extra tool to your workflow

- Tools like Vite technically do include extra tools but hide the complexity from you, so from your perspective it’s just a single tool