Bundler
Bundle TypeScript and JavaScript code, along with their dependencies, into a single file. Useful for producing self-contained scripts for distribution or deployment.
Eg Deno.bundle
function Deno.bundle
bundle(options: Deno.bundle.Options): Promise<Deno.bundle.Result>Bundle Typescript/Javascript code into a single file.
This is an unstable API and requires the --unstable-bundle flag to be passed when running Deno:
deno run --unstable-bundle main.ts
const result = await Deno.bundle({
entrypoints: ["./main.ts"],
minify: true,
});
for (const file of result.outputFiles ?? []) {
console.log(file.text());
}
Requires read access to local entrypoints and their dependency trees, import access to remote modules, and write access when output is written to the filesystem.
Parameters
options: Deno.bundle.Options Return Type
Promise<Deno.bundle.Result> namespace Deno.bundle
Interfaces
Type Aliases
The output format of the bundle.
How to handle packages.
The target platform of the bundle.
The source map type of the bundle.
interface Deno.bundle.MessageLocation
interface Deno.bundle.MessageNote
A note about a message.
Properties
text: string location: MessageLocation interface Deno.bundle.Options
Options for the bundle.
Properties
entrypoints: string[] The entrypoints of the bundle.
outputPath: string Output file path.
outputDir: string Output directory path.
external: string[] External modules to exclude from bundling.
minify: boolean Whether to minify the output.
keepNames: boolean Whether to keep function and class names.
codeSplitting: boolean Whether to enable code splitting.
inlineImports: boolean Whether to inline imports.
packages: PackageHandling How to handle packages.
sourcemap: SourceMapType Source map configuration.
write: boolean Whether to write the output to the filesystem.
interface Deno.bundle.OutputFile
type alias Deno.bundle.Format
The output format of the bundle.
Definition
"esm"
| "cjs"
| "iife"
type alias Deno.bundle.PackageHandling
How to handle packages.
-
bundle: packages are inlined into the bundle. -
external: packages are excluded from the bundle, and treated as external dependencies.
Definition
"bundle" | "external" type alias Deno.bundle.Platform
The target platform of the bundle.
Definition
"browser" | "deno" type alias Deno.bundle.SourceMapType
The source map type of the bundle.
Definition
"linked"
| "inline"
| "external"
© 2018–2025 the Deno authors
Licensed under the MIT License.
https://docs.deno.com/api/deno/bundler