Posted on 3/4/2022
I accidentally created a “lightweight TypeScript runtime” inside Node.js as part of Novo Cantico. Like the rest of the project, it’s a lot simpler than it seems:
- All nodes under under
app/*are created as FsFile and FsDir objects
- All FsFile objects have a
- For any file ending in
A tiny bit of wiring is needed to make
require work (which sucrase transforms imports into), which is entirely the purpose of the small Module class.
The Runtime class just glues this all together, provides an entry point, and has (currently incomplete) shims for timeouts/intervals.
That’s the whole runtime.
The benefit is that I can now completely load up an entire tree of TypeScript code, run it, and shut it down, instantly, all in a normal Node.js program, without needing the official TypeScript compiler or Babel installed; and sucrase is very fast.
This is the basis of both TypeScript support and hot-reloading support in Novo Cantico apps.
- How do you add routes in Novo Cantico? — 12/1/2022
- A synchronous web framework. — 11/19/2022
- Strange alternative to Express.js — 11/14/2022
- I finally made something innovative. Please donate. — 11/9/2022
- An alternative evolution of web development — 4/7/2022
- A brief history of IDEs — 3/7/2022
- How the TypeScript runtime works — 3/4/2022
- Why isn't this on NPM? — 2/28/2022
- You might not need Express.js — 2/26/2022
- Hitting the philosophical restart button on web development — 2/26/2022