---
title: "Roll your own JavaScript runtime, pt. 2"
description: "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."
url: "https://swe.quest/articles/roll-your-own-javascript-runtime-pt-2-53cebea56dc325e0"
canonical: "https://deno.com/blog/roll-your-own-javascript-runtime-pt2"
source: "Deno"
published: "2023-02-15"
difficulty: "medium"
kind: "How-to"
reading_minutes: 7
tags: ["runtimes","rust","javascript","typescript"]
---

# Roll your own JavaScript runtime, pt. 2

A post on [Deno](https://swe.quest/sources/deno.md), published 2023-02-15, 7 min read, How-to. Original: [https://deno.com/blog/roll-your-own-javascript-runtime-pt2](https://deno.com/blog/roll-your-own-javascript-runtime-pt2)

## Summary

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.

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [Runtimes & VMs](https://swe.quest/tags/runtimes.md) (Compilers & runtimes)
- [Rust](https://swe.quest/tags/rust.md) (Languages)
- [JavaScript](https://swe.quest/tags/javascript.md) (Languages)
- [TypeScript](https://swe.quest/tags/typescript.md) (Languages)

## Prerequisites

- Rust and Cargo basics ([easy posts on Rust](https://swe.quest/tags/rust.md?difficulty=easy))
- async Rust with tokio ([easy posts on Concurrency](https://swe.quest/tags/concurrency.md?difficulty=easy))
- JavaScript modules ([easy posts on JavaScript](https://swe.quest/tags/javascript.md?difficulty=easy))

## Keywords

deno\_core, deno\_ast, JsRuntime, reqwest, tokio, ModuleLoader

## Related posts

- [Roll your own JavaScript runtime](https://swe.quest/articles/roll-your-own-javascript-runtime-40ed853bc1965bed.md): Deno · 2022-07-29 · Medium · 8 min read · Runtimes & VMs, Rust, JavaScript
  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.
- [Roll your own JavaScript runtime, pt. 3](https://swe.quest/articles/roll-your-own-javascript-runtime-pt-3-dea9fc6d84e2ecd0.md): Deno · 2023-05-04 · Medium · 4 min read · Runtimes & VMs, Rust, JavaScript, Performance engineering
  V8 startup snapshots can speed up launch of a custom deno\_core-based JavaScript runtime at a typically negligible cost in binary size.
- [Wrapping My Mind Around Node.js Runtimes](https://swe.quest/articles/wrapping-my-mind-around-node-js-runtimes-e02012f26cbbaf25.md): Neon · 2024-09-18 · Easy · 8 min read · JavaScript, Runtimes & VMs, TypeScript
  Deno and Bun take different approaches to replacing Node.js as a server-side JavaScript runtime.
- [Node just added TypeScript support. What does that mean for Deno?](https://swe.quest/articles/node-just-added-typescript-support-what-does-that-mean-for-deno-14b91bca00f94e31.md): Deno · 2025-03-06 · Easy · 4 min read · TypeScript, Runtimes & VMs, Developer tools, JavaScript
  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.
- [Introducing JSR - the JavaScript Registry](https://swe.quest/articles/introducing-jsr-the-javascript-registry-68b9a9f287a6887b.md): Deno · 2024-03-01 · Medium · 10 min read · JavaScript, TypeScript, Build systems, Supply chain security, Open source
  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.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
