Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface ConfigAPI

Hierarchy

  • ConfigAPI

Index

Properties

Methods

Properties

cache

env

version

version: string

The version string for the Babel version that is loading the config file.

see

https://babeljs.io/docs/en/next/config-files#apiversion

Methods

assertVersion

  • assertVersion(versionRange: number | string): boolean
  • While api.version can be useful in general, it's sometimes nice to just declare your version. This API exposes a simple way to do that with:

    example

    api.assertVersion(7) // major version only api.assertVersion("^7.2")

    see

    https://babeljs.io/docs/en/next/config-files#apiassertversionrange

    Parameters

    • versionRange: number | string

    Returns boolean

caller

  • caller<T>(callerCallback: (caller: TransformOptions["caller"]) => T): T
  • This API is used as a way to access the caller data that has been passed to Babel. Since many instances of Babel may be running in the same process with different caller values, this API is designed to automatically configure api.cache, the same way api.env() does.

    The caller value is available as the first parameter of the callback function. It is best used with something like this to toggle configuration behavior based on a specific environment:

    example

    function isBabelRegister(caller?: { name: string }) { return !!(caller && caller.name === "@babel/register") } api.caller(isBabelRegister)

    see

    https://babeljs.io/docs/en/next/config-files#apicallercb

    Type parameters

    Parameters

    • callerCallback: (caller: TransformOptions["caller"]) => T
        • (caller: TransformOptions["caller"]): T
        • Parameters

          • caller: TransformOptions["caller"]

          Returns T

    Returns T