Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/emit/mod.ts

Transpile and bundle JavaScript and TypeScript under Deno and Deno Deploy
Go to Latest
import * as emit from "https://deno.land/x/emit@0.32.0/mod.ts";

APIs to transpile and bundle JavaScript and TypeScript under Deno and Deno.

It is a user loadable module which provides an alternative to the removed unstable Deno.emit() API.

Example - Transpiling

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

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

const { code } = result;
console.log(code.includes("export default function hello()"));

Example - Bundling

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

const { code } = result;
console.log(code);

Functions

Generate a single file JavaScript bundle of the root module and its dependencies.

Transpile TypeScript (or JavaScript) into JavaScript, returning a promise which resolves with a map of the emitted files.

Interfaces

The output of the bundle function.

Options which can be set when using the transpile function.