function
bundle.feature
flag: string
): boolean;
Checks whether a feature flag is enabled at compile time.
At bundle time, Bun replaces each call with a boolean literal (true or false) and removes the unreachable branch.
@param flag
Name of the feature flag to check
@returns
true if the flag was passed with --feature=FLAG, false otherwise
import { feature } from "bun:bundle";
// With --feature=DEBUG, this becomes: if (true) { ... }
// Without --feature=DEBUG, this becomes: if (false) { ... }
if (feature("DEBUG")) {
console.log("Debug mode enabled");
}