Check if a feature flag is enabled at compile time.
This function is replaced with a boolean literal (true or false) at bundle time, enabling dead-code elimination. The bundler will remove unreachable branches.
function
Check if a feature flag is enabled at compile time.
This function is replaced with a boolean literal (true or false) at bundle time, enabling dead-code elimination. The bundler will remove unreachable branches.
The name of the feature flag to check
true if the flag was passed via --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");
}