Skip to content

In development. Expect rough edges and changes. The source code is not public yet.

Deno 7 min read How-to mediumAdept

Roll your own JavaScript runtime, pt. 2

A custom JavaScript runtime built on deno_core gains three capabilities: a fetch op backed by the reqwest crate and registered in the runjs extension, a CLI that takes the script path as its first argument, and TypeScript/TSX support. TypeScript support comes from a custom TsModuleLoader that implements deno_core's ModuleLoader trait. It picks a MediaType from the file extension and uses deno_ast to parse and transpile TS, TSX and JSX into JavaScript before handing the module to JsRuntime. The whole runtime stays around 154 lines of Rust.

Related posts

  • Roll your own JavaScript runtime

    Deno mediumAdept

    A minimal JavaScript runtime called runjs can be built in Rust by combining the deno_core crate, which wraps a V8 isolate in a JsRuntime, with a single-threaded tokio runtime as the event loop. The tutorial loads and evaluates ES modules from disk, adds a console API in a bundled runtime.js, and exposes async and sync filesystem functions to JavaScript via #[op2] ops registered through the extension! macro. deno_core handles marshalling between JS Promises and Rust Futures, so each new native API needs only a small amount of glue code.

  • Roll your own JavaScript runtime, pt. 3

    Deno mediumAdept

    V8 startup snapshots can speed up launch of a custom deno_core-based JavaScript runtime at a typically negligible cost in binary size. A Cargo build.rs script uses deno_core's extension! macro and create_snapshot with CreateSnapshotOptions to serialize the runtime.js extension into RUNJS_SNAPSHOT.bin in OUT_DIR. main.rs then embeds the snapshot with include_bytes!, passes it as startup_snapshot in RuntimeOptions, and switches the extension to init_ops() so only the Rust ops are registered at runtime.

  • Wrapping My Mind Around Node.js Runtimes

    Neon easyNovice

    Deno and Bun take different approaches to replacing Node.js as a server-side JavaScript runtime. Deno, built by Node's creator, focuses on security with a permission sandbox, built-in TypeScript and web-standard APIs. In Deno 2 it has moved away from URL imports toward the JSR registry and Node compatibility. Bun runs on JavaScriptCore, aims for speed, and bundles a package manager, test runner, bundler, embedded SQLite and automatic .env loading. The recommendation: Node.js for long-lived projects, Deno when security or Deno Deploy matters, and Bun when performance is the priority, or just as a fast package manager, as Neon does for neonctl.

  • Node just added TypeScript support. What does that mean for Deno?

    Deno easyNovice

    Node 22.6 added TypeScript execution via type stripping (stable in 23.6), which replaces annotations with whitespace but does no type checking, does not handle JSX/TSX, and still relies on tsc and a manually managed tsconfig.json. Deno instead ships an integrated toolchain: SWC strips types, a bundled TypeScript compiler powers `deno check` and the LSP, and fmt, lint, doc and compile all understand TypeScript with zero-config defaults. Deno also supports TSX/JSX, TypeScript in the REPL and Jupyter, and publishing raw TypeScript to JSR without transpilation or separate .d.ts files.

  • Introducing JSR - the JavaScript Registry

    Deno mediumAdept

    JSR, the JavaScript Registry, is in public beta as a free, MIT-licensed, ESM-only registry built for TypeScript that works with Deno and npm-based runtimes like Node, Bun and Cloudflare Workers. Authors publish TypeScript source directly, and JSR generates API docs, .d.ts files and transpiled JavaScript for Node consumers. A walkthrough publishes a small package with jsr.json, consumes it from an Astro project via `npx jsr add`, and sets up GitHub Actions publishing with OIDC tokens and provenance transparency logs. Packages also get a quality score based on documentation, fast-type-checkable declarations and runtime compatibility.

The quest for software engineering knowledge.

Look:
Layout: