interface

TrimOptions

interface TrimOptions

  • allow?: TrimFeature[]

    Features to keep even if your code never uses them, along with the features they need.

    Use it when something the compiler can't see uses an API: a string passed to eval(), a native addon, or a module loaded at run time.

  • locales?: string[]

    The only locales to keep, such as "en" or "de-AT".

    Without it, Bun keeps the locales your code passes to Intl as constants, and every locale if one of them isn't a constant. If the program asks for a locale that was removed, the process exits with code 70. It has no effect on macOS, where Bun uses the system's ICU.

    Equivalent CLI flag: --trim-locales, which implies --trim

  • log?: boolean

    Add notes to BuildOutput.logs that list what was removed and how much smaller the executable is.

  • remove?: TrimFeature[]

    Features to remove even if your code uses them.

    Every import, global and property is still there, so typeof and in answer as before. A call throws an Error whose code is "ERR_FEATURE_REMOVED". Use it to make sure that an executable can't do something, such as load native code: remove: ["native-code"].

    A name can't be in both allow and remove.