BuildConfig

Bun

Symbol

BuildConfig

interface BuildConfig

  • banner?: string

    Add a banner to the bundled code such as "use client";

  • bytecode?: boolean

    Generate bytecode for the output. This can dramatically improve cold start times, but will make the final output larger and slightly increase memory usage.

    Bytecode is currently only supported for CommonJS (format: "cjs").

    Must be target: "bun"

  • conditions?: string | string[]

    package.json exports conditions used when resolving imports

    Equivalent to --conditions in bun build or bun run.

    https://nodejs.org/api/packages.html#exports

  • define?: Record<string, string>
  • drop?: string[]

    Drop function calls to matching property accesses.

  • emitDCEAnnotations?: boolean

    Force emitting @PURE annotations even if minify.whitespace is true.

  • entrypoints: string[]
  • env?: 'inline' | 'disable' | `${string}*`

    Controls how environment variables are handled during bundling.

    Can be one of:

    • "inline": Injects environment variables into the bundled output by converting process.env.FOO references to string literals containing the actual environment variable values
    • "disable": Disables environment variable injection entirely
    • A string ending in *: Inlines environment variables that match the given prefix. For example, "MY_PUBLIC_*" will only include env vars starting with "MY_PUBLIC_"
    Bun.build({
      env: "MY_PUBLIC_*",
      entrypoints: ["src/index.ts"],
    })
    
  • external?: string[]
  • footer?: string

    Add a footer to the bundled code such as a comment block like

    // made with bun!

  • format?: 'esm' | 'cjs' | 'iife'

    Output module format. Top-level await is only supported for "esm".

    Can be:

    • "esm"
    • "cjs" (experimental)
    • "iife" (experimental)
  • ignoreDCEAnnotations?: boolean

    Ignore dead code elimination/tree-shaking annotations such as @PURE and package.json "sideEffects" fields. This should only be used as a temporary workaround for incorrect annotations in libraries.

  • loader?: {}
  • minify?: boolean | { identifiers: boolean; syntax: boolean; whitespace: boolean }

    Whether to enable minification.

    Use true/false to enable/disable all minification options. Alternatively, you can pass an object for granular control over certain minifications.

  • naming?: string | { asset: string; chunk: string; entry: string }
  • outdir?: string
  • packages?: 'external' | 'bundle'
  • publicPath?: string
  • root?: string
  • sourcemap?: boolean | 'external' | 'none' | 'linked' | 'inline'

    Specifies if and how to generate source maps.

    • "none" - No source maps are generated
    • "linked" - A separate *.ext.map file is generated alongside each *.ext file. A //# sourceMappingURL comment is added to the output file to link the two. Requires outdir to be set.
    • "inline" - an inline source map is appended to the output file.
    • "external" - Generate a separate source map file for each input file. No //# sourceMappingURL comment is added to the output file.

    true and false are aliases for "inline" and "none", respectively.

  • splitting?: boolean
  • throw?: boolean

    When set to true, the returned promise rejects with an AggregateError when a build failure happens. When set to false, the success property of the returned object will be false when a build failure happens. This defaults to true.