contains the relevant fields within the configuration json file, that are used for configuring distribution generation.

interface CliDistConfig {
    dir?: string;
    deno?: string;
    log?:
        | boolean
        | "none"
        | "basic"
        | "verbose";
    dryrun?: boolean;
    passes?: "1" | "2";
    split?: boolean;
    minify?:
        | boolean
        | "syntax"
        | "whitespace"
        | "identifiers";
    format?: any;
    input?:
        | null
        | string
        | string[]
        | {
            [output_name: string]: string;
        };
    copy?: [source: string, destination: string][];
    text?: WritableFileConfig[];
    esbuild?: Omit<EsBuildOptions,
        | "outdir"
        | "outfile"
        | "plugins"
        | "entryPoints">;
    transform?: TransformationCliConfig[];
}

Hierarchy

  • Omit<CliArgs, "config">
    • CliDistConfig

Properties

dir?: string

the path to the folder where you wish to create your distribution release. if a relative path is provided, then it will be resolved as a path relative to Deno's current working directory. (which is generally where deno.json resides.) the directory provided here will serve as esbuild configuration's ["outdir"] | outdir option.

deno?: string

the path to your deno.json file for this project. if a relative path is provided, then it will be resolved as a path relative to Deno's current working directory. (which is also where deno.json generally resides.)

log?:
    | boolean
    | "none"
    | "basic"
    | "verbose"

select logging level:

  • false or "none": skip logging (dnt itself will still log).
  • true or "basic": log what is being carried out at the top level.
  • "verbose": in addition to basic logging, it also logs which files/folders are being copied or generated.
  • undefined: unchange logging from previous state (which is "basic" by default).
dryrun?: boolean

enable dryrun if you wish for nothing to be written onto the the filesystem.

passes?: "1" | "2"

specify the number of compilation passes to perform:

  • "1" implies a single-pass compilation, and only uses the buildDist function under the hood.
  • "2" implies a double-pass compilation, which consists of two compilations, and is performed in the following set of steps:
    1. your source files are first bundled in-memory via the bundle function (which uses esbuild's build api).
    2. the resulting virtual files are then individually transformed via the transform function (which uses esbuild's transform api).
      you can configure this step through custom transformation functions and capture patterns, by specifying them in the TransformationCliConfig.pattern field of your CliConfigJson. but by default, only javascript files are further minified. (no css minification or transformation of other file/content types). see the default transformation here.
    3. the virtual files emitted by the transform function are then fed to the createFiles utility function which writes them onto your filesystem.

"1"

split?: boolean

enable esbuild's code splitting option.
you will probably want this turned on if you are transpiling multiple entry-points, so that the distribution files are overall shared and smaller in size.

false

minify?:
    | boolean
    | "syntax"
    | "whitespace"
    | "identifiers"

minify the output code, or apply minification of only one type ("syntax", "whitespace", or "identifiers").
note that when minify is true, EsBuildOptions.treeShaking also occurs by default.

"syntax"

format?: any

{@inheritDoc dist!EsBuildOptions.format}

"esm"

input?:
    | null
    | string
    | string[]
    | {
        [output_name: string]: string;
    }

the collection of files to compile. this option translates into esbuild's entryPoints configuration field.
if this is not provided, then the exports field is used from your deno.json as the entry points for esbuild.

copy?: [source: string, destination: string][]

a list of paths/glob patterns relative to the deno.json directory, that should be copied over to the build directory, at the specified path. note that if the source is a glob pattern, then its destination can only be a folder. moreover, folder sources and destinations must always end in a trailing slash (i.e. "./path/to/my/folder/")

[!CAUTION] be cautious with using glob patterns with folders, as it will generally give you a bad unexpected output. when using glob patterns, make sure to execute a dryrun of the build process with "verbose" logging, to ensure that you are getting your desired copy paths.

write (or append) additional text or binary files to the output build directory, at the specified relative destination. use the 3rd options item to specify text Deno.WriteFileOptions | writing options, such as "append" the new text, or permit the creation ("create") of new file if it doesn't exist, etc...

esbuild?: Omit<EsBuildOptions,
    | "outdir"
    | "outfile"
    | "plugins"
    | "entryPoints">

esbuild related additional build options for you to configure.
note that outdir and outfile options are made unavailable, since they are controlled by your dir value.
in addition, esbuild plugins must be configured via plugins.

when using two passes (i.e. passes === "2"), in the second stage compilation (transformation), the transformations listed in this array will be applied sequentially to whichever output file that matches the given glob pattern.

by default, when nothing is provided, only javascript esm-minification transformation will take place. meaning that it will take shape of the following default value:

[{ pattern: "./**/*.js", loader: "js", options: { minify: true, platform: "browser", format: "esm", target: "esnext" } }, ]