Spec-Zone.ru › Deno 2

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

unstable
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

unstable

Interfaces

Deno.bundle.Message

A message emitted from the bundler.

  • location
  • notes
  • text
Deno.bundle.MessageLocation

The location of a message.

  • column
  • file
  • length
  • line
  • namespace
  • suggestion
Deno.bundle.MessageNote

A note about a message.

  • location
  • text
Deno.bundle.Options

Options for the bundle.

  • codeSplitting
  • entrypoints
  • external
  • format
  • inlineImports
  • keepNames
  • minify
  • outputDir
  • outputPath
  • packages
  • platform
  • sourcemap
  • write
Deno.bundle.OutputFile

An output file in the bundle.

  • contents
  • hash
  • path
  • text
Deno.bundle.Result

The result of bundling.

  • errors
  • outputFiles
  • success
  • warnings

Type Aliases

Deno.bundle.Format

The output format of the bundle.

Deno.bundle.PackageHandling

How to handle packages.

Deno.bundle.Platform

The target platform of the bundle.

Deno.bundle.SourceMapType

The source map type of the bundle.


interface Deno.bundle.Message

unstable

A message emitted from the bundler.

Properties

text: string
location: MessageLocation
optional
notes: MessageNote[]
optional

interface Deno.bundle.MessageLocation

unstable

The location of a message.

Properties

file: string
namespace: string
optional
line: number
column: number
length: number
suggestion: string
optional

interface Deno.bundle.MessageNote

unstable

A note about a message.

Properties

text: string
location: MessageLocation
optional

interface Deno.bundle.Options

unstable

Options for the bundle.

Properties

entrypoints: string[]

The entrypoints of the bundle.

outputPath: string
optional

Output file path.

outputDir: string
optional

Output directory path.

external: string[]
optional

External modules to exclude from bundling.

format: Format
optional

Bundle format.

minify: boolean
optional

Whether to minify the output.

keepNames: boolean
optional

Whether to keep function and class names.

codeSplitting: boolean
optional

Whether to enable code splitting.

inlineImports: boolean
optional

Whether to inline imports.

packages: PackageHandling
optional

How to handle packages.

sourcemap: SourceMapType
optional

Source map configuration.

platform: Platform
optional

Target platform.

write: boolean
optional

Whether to write the output to the filesystem.


interface Deno.bundle.OutputFile

unstable

An output file in the bundle.

Properties

path: string
contents: Uint8Array<ArrayBuffer>
optional
hash: string

Methods

text(): string

interface Deno.bundle.Result

unstable

The result of bundling.

Properties

errors: Message[]
warnings: Message[]
success: boolean
outputFiles: OutputFile[]
optional

type alias Deno.bundle.Format

unstable

The output format of the bundle.

Definition

"esm"
| "cjs"
| "iife"

type alias Deno.bundle.PackageHandling

unstable

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

unstable

The target platform of the bundle.

Definition

"browser" | "deno"

type alias Deno.bundle.SourceMapType

unstable

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

Spec-Zone.ru

Настройки Оффлайн Что нового Помощь О нас
Spec-Zone .ru
спецификации, руководства, описания, API