Options
All
  • Public
  • Public/Protected
  • All
Menu

External module "node_modules/@types/babel__core/index.d"

Index

Type aliases

ConfigFunction

ConfigFunction: function

Type declaration

FileParseCallback

FileParseCallback: function

Type declaration

FileResultCallback

FileResultCallback: function

Type declaration

Node

Node: t.Node

ParseResult

ParseResult: File | Program

PluginItem

PluginItem: ConfigItem | PluginObj<any> | PluginTarget | [PluginTarget, PluginOptions] | [PluginTarget, PluginOptions, string | undefined]

PluginOptions

PluginOptions: object | undefined | false

PluginTarget

PluginTarget: string | object | function

SimpleCacheCallback

SimpleCacheCallback<T>: function

Type parameters

Type declaration

    • (): T
    • Returns T

SimpleCacheKey

SimpleCacheKey: string | boolean | number | null | undefined

Variables

Const DEFAULT_EXTENSIONS

DEFAULT_EXTENSIONS: [".js", ".jsx", ".es6", ".es", ".mjs"]

Const version

version: string

Functions

createConfigItem

  • Allows build tooling to create and cache config items up front. If this function is called multiple times for a given plugin, Babel will call the plugin's function itself multiple times. If you have a clear set of expected plugins and presets to inject, pre-constructing the config items would be recommended.

    Parameters

    Returns ConfigItem

loadOptions

  • Resolve Babel's options fully, resulting in an options object where:

    • opts.plugins is a full list of Plugin instances.
    • opts.presets is empty and all presets are flattened into opts.
    • It can be safely passed back to Babel. Fields like babelrc have been set to false so that later calls to Babel will not make a second attempt to load config files.

    Plugin instances aren't meant to be manipulated directly, but often callers will serialize this opts to JSON to use it as a cache key representing the options Babel has received. Caching on this isn't 100% guaranteed to invalidate properly, but it is the best we have at the moment.

    Parameters

    Returns object | null

loadPartialConfig

  • To allow systems to easily manipulate and validate a user's config, this function resolves the plugins and presets and proceeds no further. The expectation is that callers will take the config's .options, manipulate it as then see fit and pass it back to Babel again.

    • babelrc: string | void - The path of the .babelrc file, if there was one.
    • babelignore: string | void - The path of the .babelignore file, if there was one.
    • options: ValidatedOptions - The partially resolved options, which can be manipulated and passed back to Babel again.
      • plugins: Array<ConfigItem> - See below.
      • presets: Array<ConfigItem> - See below.
      • It can be safely passed back to Babel. Fields like babelrc have been set to false so that later calls to Babel will not make a second attempt to load config files.

    ConfigItem instances expose properties to introspect the values, but each item should be treated as immutable. If changes are desired, the item should be removed from the list and replaced with either a normal Babel config value, or with a replacement item created by babel.createConfigItem. See that function for information about ConfigItem fields.

    Parameters

    Returns Readonly<PartialConfig> | null

parse

  • Given some code, parse it using Babel's standard behavior. Referenced presets and plugins will be loaded such that optional syntax plugins are automatically enabled.

    Parameters

    Returns void

  • Given some code, parse it using Babel's standard behavior. Referenced presets and plugins will be loaded such that optional syntax plugins are automatically enabled.

    Parameters

    Returns void

  • Given some code, parse it using Babel's standard behavior. Referenced presets and plugins will be loaded such that optional syntax plugins are automatically enabled.

    Parameters

    Returns ParseResult | null

parseAsync

  • Given some code, parse it using Babel's standard behavior. Referenced presets and plugins will be loaded such that optional syntax plugins are automatically enabled.

    Parameters

    Returns Promise<ParseResult | null>

parseSync

  • Given some code, parse it using Babel's standard behavior. Referenced presets and plugins will be loaded such that optional syntax plugins are automatically enabled.

    Parameters

    Returns ParseResult | null

resolvePlugin

  • resolvePlugin(name: string, dirname: string): string | null
  • Parameters

    • name: string
    • dirname: string

    Returns string | null

resolvePreset

  • resolvePreset(name: string, dirname: string): string | null
  • Parameters

    • name: string
    • dirname: string

    Returns string | null

transform

  • Transforms the passed in code. Calling a callback with an object with the generated code, source map, and AST.

    Parameters

    Returns void

  • Transforms the passed in code. Calling a callback with an object with the generated code, source map, and AST.

    Parameters

    Returns void

  • Here for backward-compatibility. Ideally use transformSync if you want a synchronous API.

    Parameters

    Returns BabelFileResult | null

transformAsync

  • Transforms the passed in code. Calling a callback with an object with the generated code, source map, and AST.

    Parameters

    Returns Promise<BabelFileResult | null>

transformFile

  • Asynchronously transforms the entire contents of a file.

    Parameters

    Returns void

  • Asynchronously transforms the entire contents of a file.

    Parameters

    Returns void

transformFileAsync

  • Asynchronously transforms the entire contents of a file.

    Parameters

    Returns Promise<BabelFileResult | null>

transformFileSync

  • Synchronous version of babel.transformFile. Returns the transformed contents of the filename.

    Parameters

    Returns BabelFileResult | null

transformFromAst

  • Given an AST, transform it.

    Parameters

    Returns void

  • Given an AST, transform it.

    Parameters

    Returns void

transformFromAstAsync

  • Given an AST, transform it.

    Parameters

    Returns Promise<BabelFileResult | null>

transformFromAstSync

  • Here for backward-compatibility. Ideally use ".transformSync" if you want a synchronous API.

    Parameters

    Returns BabelFileResult | null

transformSync

  • Transforms the passed in code. Returning an object with the generated code, source map, and AST.

    Parameters

    Returns BabelFileResult | null

Generated using TypeDoc