Pfeatures
Bun

property

NormalBuildConfig.features

features?: string[]

Enable feature flags for dead-code elimination via import { feature } from "bun:bundle".

When feature("FLAG_NAME") is called, it returns true if FLAG_NAME is in this array, or false otherwise. This enables static dead-code elimination at bundle time.

Equivalent to the CLI --feature flag.

await Bun.build({
  entrypoints: ['./src/index.ts'],
  features: ['FEATURE_A', 'FEATURE_B'],
});