Deno’s codebase - and most of what we build around it - is open source under the permissive MIT license. Over the years, we’ve published dozens of supporting libraries and tools that solve common problems we’ve run into while building Deno. Here are a few we think others may find useful.
- rusty_v8: Rust bindings to the V8 JavaScript engine
- deno_core: builds on rusty_v8 to provide higher level functionality, like mapping JavaScript Promises to Rust Futures
- rust-urlpattern: implements URLPattern web API in Rust
- import_map: implements the import map spec in Rust
- eszip and eszip_viewer: a binary file format for distributing an entire module graph of TypeScript files
- sui: a library for embedding data executable files in a cross platform way
- dnt: Deno to npm package build tool
- wasmbuild: Build tool to use Rust code in Deno and the browser
- monch: lightweight parser, similar to nom, focused on strings
- deno_task_shell: cross-platform shell for deno task.
- flaky_test: atttribute macro for running a flaky test multiple times
- vnotify: monitor millions of S3 objects without external dependencies
- What’s next
Rusty V8
Rusty V8 provides high-quality, zero-overhead Rust bindings to V8’s C++ API, and is the core of the Deno runtime. We made this library, which has undergone over 150 releases and downloaded more than 3 million times on crates.io, stable and production ready last year. You can use Rusty V8 to build custom JavaScript runtimes, run WebAssembly modules, use the V8 Fast API, and much more.
Here’s an example of how you can embed JavaScript in a Rust program with rusty_v8:
deno_core
The deno_core crate, builds on Rusty V8. Where Rusty V8 is truly exposes V8’s C++ API as directly as possible in Rust, deno_core adds “ops” and an event loop. Practically it maps JavaScript Promises onto Rust Futures. The “ops” are marcos which allow users to define functions that cross the boundary between JavaScript and Rust as efficently as possible (using V8’s Fast API where possible).
We’ve written some blog posts about how one can use deno_core to quickly roll your own JavaScript runtime.
Although deno_core adds a lot on top of Rusty V8, it still lacks many things from the main deno runtime - it has no concept of TypeScript, it has very few APIs - no fetch() - and certainly no built-in node modules.
rust-urlpattern
This crate implements the URLPattern web API in Rust, following the specification as closely as possible. We use this …
import_map
import_map is a Rust crate implementing the WICG Import Maps specification. An import map is a JSON file that lets you control how module specifiers resolve to actual URLs in JavaScript and TypeScript. We use this library to parse and apply import maps.
You can use import_map to create and map custom specifiers like "my-lib" to a full URL:
eszip and eszip_viewer
The eszip format lets you losslessly serialize an ECMAScript module graph into a single compact file, allowing efficient storage and transmission of code as a single package. This is useful for creating standalone archives of JavaScript or TypeScript projects, or caching module graphs. It also supports streaming, so large module bundles can be loaded efficiently.
We use eszip for quickly loading JavaScript and TypeScript in Deno Deploy. We also have eszip_viewer to easily view eszip formats.
sui
sui is a Rust library (named after the Hindi word for “needle”) that lets you embed data into executable files (ELF on Linux, PE on Windows, Mach-O on macOS), which can be extracted later. This is useful for bundling assets or configuration inside a binary without external files. sui produces valid executables that can be code-signed on macOS and Windows. We use sui in deno compile to minimize binary size and for code signing.
dnt
dnt (Deno to npm transform) is a build tool that converts a Deno module into a format publishable to npm by shimming Deno-specific globals, rewriting import statements, and outputting types and CommonJS versions. This allows module authors to easily publish hybrid npm modules for ESM and CommonJS.
Here’s an example of using dnt in a build script to package your ES module:
wasmbuild
This CLI simplifies the process of building and using Rust code in Deno and the browser. It generates glue code for calling into Rust crates via wasm-bindgen. The output can be easily consumed in Javascript via Wasm. This tool is great in situations where you might want to call a complex algorithm in Rust from JavaScript, or run Rust code that is more efficient than in JavaScript.
For a more full example, check out wasmbuild_example .
monch
This rust crate is a light-weight parser combinator library inspired by nom. It was created to provide a more targeted library for parsing strings and added some combinators we found useful. In Deno, monch is used to parse the deno task command strings and other similar situations.
deno_task_shell
deno_task_shell is a cross-platform shell implementation for parsing and executing scripts. We use this in deno task.
flaky_test
flaky_test is a Rust attribute macro that helps manage flaky tests by running a test multiple times and only failing it if it fails every time. This is useful for tests that are known to be flaky (due to non deterministic issues like network or availability). By default, the macro runs the marked test three times. If at least one run passes, the overall test is considered passed.
vnotify
vnotify (short for “vectorized notification”) is a Rust library for efficiently monitoring changes in Amazon S3 buckets that contain millions of objects. It achieves this without any external services using a clever hashing strategy: when an object in S3 is updated, vnotify writes a small notification file under a special prefix. Clients can quickly check a fixed set of these notifications to detect updates across the whole bucket with one or two S3 API calls. This is useful for caching or syncing scenarios where you want to know if any object in a huge bucket changed without scanning the entire bucket.
What’s next
These open source projects not only power Deno, but also used across the broader developer ecosystem. We’ll continue to build tools that make development simpler and more secure, and hope you’ll explore and build something great with them.
.png)
