Skip to main content
Module

x/cav/deps.ts>emit.emit

A server framework for Deno
Go to Latest
interface emit.emit
Re-export
import { type emit } from "https://deno.land/x/cav@0.0.24/deps.ts";
const { emit } = emit;

The output of the bundle function.

Properties

code: string

The bundles code as a single JavaScript module.

optional
map: string

An optional source map.

Properties

optional
allowRemote: boolean

Allow remote modules to be loaded or read from the cache.

optional
cacheRoot: string

The cache root to use, overriding the default inferred DENO_DIR.

optional
cacheSetting: CacheSetting

The setting to use when loading sources from the Deno cache.

optional
compilerOptions: CompilerOptions

Compiler options which can be set when bundling.

optional
imports: Record<string, string[]>
optional
load: FetchCacher["load"]

Override the default loading mechanism with a custom loader. This can provide a way to use "in-memory" resources instead of fetching them remotely.

optional
type: "module" | "classic"

Should the emitted bundle be an ES module or an IIFE script. The default is "module" to output a ESM module.

Properties

optional
allowRemote: boolean

Allow remote modules to be loaded or read from the cache.

optional
cacheRoot: string

The cache root to use, overriding the default inferred DENO_DIR.

optional
cacheSetting: CacheSetting

The setting to use when loading sources from the Deno cache.

optional
load: FetchCacher["load"]

Override the default loading mechanism with a custom loader. This can provide a way to use "in-memory" resources instead of fetching them remotely.

Properties

optional
checkJs: boolean
optional
emitDecoratorMetadata: boolean

Determines if reflection meta data is emitted for legacy decorators or not. Defaults to false.

optional
importsNotUsedAsValues: string
optional
inlineSourceMap: boolean

When set, instead of writing out a .js.map file to provide source maps, the source map will be embedded the source map content in the .js files.

Although this results in larger JS files, it can be convenient in some scenarios. For example, you might want to debug JS files on a webserver that doesn’t allow .map files to be served.

optional
inlineSources: boolean

When set, the original content of the .ts file as an embedded string in the source map (using the source map’s sourcesContent property).

This is often useful in the same cases as inlineSourceMap.

optional
jsx: "jsx" | "preserve"

Controls how JSX constructs are emitted in JavaScript files. This only affects output of JS files that started in .jsx or .tsx files.

optional
jsxFactory: string

Changes the function called in .js files when compiling JSX Elements using the classic JSX runtime. The most common change is to use "h" or "preact.h".

optional
jsxFragmentFactory: string

Specify the JSX fragment factory function to use when targeting react JSX emit with jsxFactory compiler option is specified, e.g. Fragment.

optional
sourceMap: boolean

Enables the generation of sourcemap files.

function emit.emit
Re-export
import { emit } from "https://deno.land/x/cav@0.0.24/deps.ts";
const { emit } = emit;

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

Parameters

root: string | URL

The root module specifier to use for the bundle.

optional
options: EmitOptions = [UNSUPPORTED]

Options to use when emitting.

Returns

Promise<Record<string, string>>

A promise which resolves with an object map of the emitted files, where the key is the emitted files name and the value is the source for the file.

module doc emit.emit
Re-export
import { emit } from "https://deno.land/x/cav@0.0.24/deps.ts";
const { emit } = emit;

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 { emit } from "https://deno.land/x/emit/mod.ts";

const url = new URL("./testdata/mod.ts", import.meta.url);
const result = await emit(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);