9 breaking releases

Uses new Rust 2021

0.9.0 Sep 7, 2022
0.7.0 Aug 24, 2022
0.4.0 Jul 11, 2022

#17 in #deno

Download history 875/week @ 2022-06-06 1079/week @ 2022-06-13 1214/week @ 2022-06-20 1361/week @ 2022-06-27 1387/week @ 2022-07-04 1348/week @ 2022-07-11 1257/week @ 2022-07-18 1295/week @ 2022-07-25 1048/week @ 2022-08-01 1122/week @ 2022-08-08 1402/week @ 2022-08-15 1713/week @ 2022-08-22 1606/week @ 2022-08-29 1843/week @ 2022-09-05 1613/week @ 2022-09-12 1341/week @ 2022-09-19

6,533 downloads per month
Used in 6 crates (4 directly)

MIT license

402 lines


deno emit Twitter handle Discord Chat

Transpile and bundle JavaScript and TypeScript in Deno and Deno Deploy.

This is an unstable module, where the API is likely to change over time.

Why was Deno.emit() removed from Deno?

In Deno 1.22 the unstable API Deno.emit() was removed. This module provides similar functionality as an optional user loaded module.

Having any APIs that are platform specific (e.g. in the Deno namespace) makes code a lot less portable. We have generally avoided adding APIs to the Deno namespace if we can. While Deno.emit() and similar APIs have been part of the unstable features for an extended period of time, creating deno_emit, deno_doc and deno_cache, which expose some of the internal Deno APIs as user loadable modules has proven to be a good pattern for giving the command line power of the Deno CLI to build end-user solutions, which also then can work on edge compute like Deno Deploy.

So while taking away functionality from the Deno CLI may seem like a strange decision, by moving it to a user loadable module, it provides users more choice and flexibility.

Note: the examples below use "unpinned" version of the module. Consider using a "pinned" version (e.g. https://deno.land/x/emit@0.0.1/mod.ts instead.)


Take individual modules that are JavaScript or TypeScript and emit them in a transpiled fashion. An example of taking some TypeScript and transpiling to JavaScript:

import { emit } from "https://deno.land/x/emit/mod.ts";

const url = new URL("./testdata/mod.ts", import.meta.url);
const result = await emit(url);

const code = result[url.href];
console.log(code.includes("export default function hello()"));


Take a root module and all its dependencies and emit a single JavaScript bundle. This is similar to the functionality provided by deno bundle on the Deno command line. An example:

import { bundle } from "https://deno.land/x/emit/mod.ts";
const result = await bundle(
  new URL("https://deno.land/std@0.140.0/examples/chat/server.ts"),

const { code } = result;

Type checking

Currently emit does not perform type checking, while the prior Deno.emit() could. Getting type checking to run under Deno is a complex process. While we want to provide a user loadable solution for this, it is unlikely that it will be provided as part of this module, or would exist as a separate loadable module as part of this one.

Copyright 2018-2022 the Deno authors. All rights reserved. MIT License.


~652K SLoC