Hacker News new | ask | show | jobs
by tsdlts 1867 days ago
After using esbuild and experiencing fast builds, I'll never go back to tools written in javascript/typescript again.
1 comments

FWIW, sucrase (written in TypeScript) has done a great job of being in the same ordinal of perf as esbuild: https://github.com/alangpierce/sucrase#sucrase
Sucrase "cheats" though[0]:

> Sucrase bypasses most of these steps, and works like this: Tokenize the input source code into a token stream using a trimmed-down fork of the Babel parser. This fork does not produce a full AST, but still produces meaningful token metadata specifically designed for the later transforms.

While this is fine for simple transformations like transpiling JSX, it's not very suitable for full-on AST analysis like some eslint plugins do. Most notoriously, Sucrase is specifically designed to be garbage-in-garbage-out, whereas Babel will throw proper errors on things like early errors.

Tools written in lower level languages like esbuild can take advantage of facilities that aren't well supported in Node, such as cheap concurrent coroutines and greater control over memory layout (Babel ASTs are notoriously megamorphic and can silently fall off perf cliffs depending on how you manipulate them). These caveats are not reflected in Sucrase's benchmark.

[0] https://github.com/alangpierce/sucrase#motivation

That's single threaded perf, so takes away a huge advantage of Go. Also doesn't include startup time (node is slow to start)
And memory usage.