Spec-Zone.ru › Deno 2

deno bundle

Info
deno bundle is currently an experimental subcommand and is subject to changes.

deno bundle combines your module and all of its dependencies into a single JavaScript file, using esbuild under the hood. It is useful for deploying or distributing a project as a single optimized file, but it is not currently intended as a replacement for complex or interactive build tools such as Vite or webpack.

Basic usage

›_
deno bundle -o output.js main.ts

Without -o/--output, the bundle is written to standard output. The output file can then be run with Deno or in other JavaScript runtimes:

›_
deno run output.js

Common options

Target a platform with --platform (deno by default, or browser), shrink the output with --minify, and emit source maps with --sourcemap:

›_
deno bundle --platform=browser --minify --sourcemap -o dist/app.js main.ts

Split shared code into separate chunks with --code-splitting and an output directory:

›_
deno bundle --code-splitting --outdir dist/ main.ts worker.ts

Keep a dependency out of the bundle with --external:

›_
deno bundle --external npm:sharp -o output.js main.ts

Generate TypeScript declarations alongside the JS output with --declaration. Deno rolls up the types for each entry point into a single self-contained .d.ts file:

›_
deno bundle main.ts --outdir dist --declaration
# Produces dist/main.js and dist/main.d.ts

Type checking

deno bundle does not type-check your code by default. Enable type-checking with the --check flag:

›_
# type-check local modules while bundling
deno bundle --check -o output.js main.ts

# also type-check remote modules
deno bundle --check=all -o output.js main.ts

You can also skip type-checking explicitly with --no-check, and --no-check=remote ignores diagnostics from remote modules only.

The browser field

When bundling with --platform=browser, Deno honors the npm browser field in a dependency's package.json, including its object form. The object maps modules to browser-specific replacements:

{
  "browser": {
    "./server.js": "./client.js",
    "crypto": false,
    "foo": "./shims/foo.js"
  }
}
  • A relative-path key remaps a resolved file to a browser-specific one (./server.js becomes ./client.js).
  • A bare-specifier key remaps an import (foo becomes ./shims/foo.js). A leading node: prefix is stripped before lookup, so import "node:crypto" matches the "crypto" key.
  • A value of false excludes the module: the bundler substitutes an empty stub.

For more on bundling strategies with Deno, see the Bundling guide.

Command line usage:
deno bundle [OPTIONS] [file]...

Output a single JavaScript file with all dependencies.

deno bundle jsr:@std/http/file-server -o file-server.bundle.js

If no output file is given, the output is written to standard output:

deno bundle jsr:@std/http/file-server

Type checking options

--check<CHECK_TYPE>optional

Enable type-checking. This subcommand does not type-check by default; pass --check=all to also type-check remote modules. Alternatively, use the 'deno check' subcommand.

--no-check<NO_CHECK_TYPE>optional

Skip type-checking. If the value of "remote" is supplied, diagnostic errors from remote modules will be ignored.

Dependency management options

--frozen<BOOLEAN>optional

Error out if lockfile is out of date.

--import-map<FILE>

Load import map file from local file or remote URL.

--lock<FILE>optional

Check the specified lock file. (If value is not provided, defaults to "./deno.lock").

--no-lock

Disable auto discovery of the lock file.

--no-npm

Do not resolve npm modules.

--no-remote

Do not resolve remote modules.

--node-modules-dir<MODE>optional

Selects the node_modules directory mode for npm packages (not a path). One of: auto (create a local node_modules directory and install npm packages into it), manual (use the existing local node_modules directory, do not modify it), none (do not use a local node_modules directory; resolve npm packages from the global cache). Defaults to auto when the flag is passed without a value.

--node-modules-linker<MODE>

Sets the linker mode for npm packages (isolated or hoisted).

--reload, -r<CACHE_BLOCKLIST>optional

Reload source code cache (recompile TypeScript). With no value, reloads everything. Pass a comma-separated list of specifiers to reload only those modules; npm: reloads all npm modules; npm:chalk reloads a single npm module; jsr:@std/http/file-server,jsr:@std/assert/assert-equals reloads specific modules.

--vendor<vendor>optional

Toggles local vendor folder usage for remote modules and a node_modules folder for npm packages.

Options

--allow-import, -I<IP_OR_HOSTNAME>optional

Allow importing from remote hosts. Optionally specify allowed IP addresses and host names, with ports as necessary. Default value: deno.land:443,jsr.io:443,esm.sh:443,raw.esm.sh:443,cdn.jsdelivr.net:443,raw.githubusercontent.com:443,gist.githubusercontent.com:443.

--allow-scripts<PACKAGE>optional

Allow running npm lifecycle scripts for the given packages Note: Scripts will only be executed when using a node_modules directory (--node-modules-dir).

--cert<FILE>

Load certificate authority from PEM encoded file.

--code-splitting

Enable code splitting.

--conditions<conditions>

Use this argument to specify custom conditions for npm package exports. You can also use DENO_CONDITIONS env var. .

--config, -c<FILE>

Configure different aspects of deno including TypeScript, linting, and code formatting. Typically the configuration file will be called deno.json or deno.jsonc and automatically detected; in that case this flag is not necessary.

--declaration

Generate .d.ts declaration files alongside the bundle.

--deny-import<IP_OR_HOSTNAME>optional

Deny importing from remote hosts. Optionally specify denied IP addresses and host names, with ports as necessary.

--env-file<FILE>optional

Load environment variables from local file Only the first environment variable with a given key is used. Existing process environment variables are not overwritten, so if variables with the same names already exist in the environment, their values will be preserved. Where multiple declarations for the same environment variable exist in your .env file, the first one encountered is applied. This is determined by the order of the files you pass as arguments.

--external<external>
--format<format>
--inline-imports<inline-imports>optional

Whether to inline imported modules into the importing file [default: true]

--keep-names

Keep function and class names.

--minify

Minify the output.

--minimum-dependency-age<minimum-dependency-age>

(Unstable) The age in minutes, ISO-8601 duration or RFC3339 absolute timestamp (e.g. '120' for two hours, 'P2D' for two days, '2025-09-16' for cutoff date, '2025-09-16T12:00:00+00:00' for cutoff time, '0' to disable).

--no-config

Disable automatic loading of the configuration file.

--outdir<outdir>

Output directory for bundled files.

--output, -o<output>

Output path`.

--packages<packages>

How to handle packages. Accepted values are 'bundle' or 'external'.

--platform<platform>

Platform to bundle for. Accepted values are 'browser' or 'deno'.

--sourcemap<sourcemap>optional

Generate source map. Accepted values are 'linked', 'inline', or 'external'.

--watch

Watch and rebuild on changes.

Last updated on June 24, 2026

© 2018–2025 the Deno authors
Licensed under the MIT License.
https://docs.deno.com/runtime/reference/cli/bundle

Spec-Zone.ru

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