AbsoluteJS

Bun Build Options

Customize selected Bun BuildConfig options for AbsoluteJS's generated app bundles without overriding framework-owned build behavior.

#Overview

Add a bunBuild field to absolute.config.ts when a project needs to tune Bun's build behavior. It accepts Bun's own build options where they are safe for AbsoluteJS to expose.

The option supports both valid config shapes: single-service configs where service fields live at the root, and multi-service workspace configs where each named Absolute service has its own service object.

#Single-Service Config

For the common one-service shape, put bunBuild at the root of the config:

TS
// absolute.config.ts
import { defineConfig } from '@absolutejs/absolute';

export default defineConfig({
  entry: 'src/backend/server.ts',
  reactDirectory: './src/frontend',
  bunBuild: {
    reactClient: {
      minify: {
        whitespace: true,
        syntax: true,
        identifiers: false
      }
    },
    nonReactClient: {
      minify: {
        whitespace: true,
        syntax: true,
        identifiers: false
      }
    },
    islandClient: {
      minify: {
        whitespace: true,
        syntax: true,
        identifiers: false
      }
    }
  }
});

#Multi-Service Config

For workspace configs, put bunBuild inside the named Absolute service. Command services do not use Absolute's Bun build pipeline.

TS
// absolute.config.ts
import { defineConfig } from '@absolutejs/absolute';

export default defineConfig({
  app: {
    entry: 'src/backend/server.ts',
    reactDirectory: './src/frontend',
    bunBuild: {
      reactClient: {
        minify: {
          whitespace: true,
          syntax: true,
          identifiers: false
        }
      }
    }
  },
  worker: {
    kind: 'command',
    command: ['bun', 'run', 'src/worker.ts']
  }
});

#Shorthand Defaults

Passing a Bun build options object directly applies it as the default override for every Absolute Bun build pass.

TS
// absolute.config.ts
import { defineConfig } from '@absolutejs/absolute';

export default defineConfig({
  entry: 'src/backend/server.ts',
  reactDirectory: './src/frontend',
  bunBuild: {
    sourcemap: 'linked',
    drop: ['console']
  }
});

#Per-Pass Overrides

Use default plus pass keys when different bundles need different Bun settings. Pass-specific values override default.

TS
// absolute.config.ts
import { defineConfig } from '@absolutejs/absolute';

export default defineConfig({
  entry: 'src/backend/server.ts',
  reactDirectory: './src/frontend',
  vueDirectory: './src/vue',
  bunBuild: {
    default: {
      sourcemap: 'linked'
    },
    reactClient: {
      minify: false
    },
    nonReactClient: {
      minify: {
        whitespace: true,
        syntax: true,
        identifiers: false
      }
    },
    vueCss: {
      naming: '[name].[hash].[ext]'
    }
  }
});

#Pass Keys

Each key maps to one internal Bun.build() pass:

TS
type BunBuildPassKey =
  | 'server'
  | 'reactClient'
  | 'nonReactClient'
  | 'islandClient'
  | 'globalCss'
  | 'vueCss';
servercompiled Svelte, Vue, and Angular server modules.
reactClientReact page and generated index client entries.
nonReactClientSvelte, Vue, Angular, HTML, HTMX, island bootstrap, and URL-referenced client entries.
islandClientgenerated island client entries.
globalCssglobal CSS entry points.
vueCssCSS emitted by Vue compilation.

#Allowed Options

The type is derived from Bun's public BuildConfig, so new compatible Bun fields can be exposed without AbsoluteJS redefining Bun's API. Common options include:

  • minify
  • sourcemap
  • drop
  • ignoreDCEAnnotations
  • loader
  • conditions
  • env
  • banner
  • footer
  • metafile
  • splitting
  • naming
  • tsconfig
  • plugins
  • external
  • define

plugins, external, and define merge with AbsoluteJS's internal values instead of replacing them.

#Reserved Fields

AbsoluteJS owns fields that affect routing, output layout, runtime target, and build error handling. These fields are rejected by TypeScript and ignored at runtime if forced through with an unsafe cast.

TS
// These Bun BuildConfig fields are owned by AbsoluteJS
// and cannot be configured through bunBuild.
type ReservedBunBuildConfigKey =
  | 'entrypoints'
  | 'outdir'
  | 'outfile'
  | 'root'
  | 'target'
  | 'format'
  | 'throw'
  | 'compile';