Resolve Babel's options fully, resulting in an options object where:
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.
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.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.
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.
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.
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.
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.
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.
Transforms the passed in code. Calling a callback with an object with the generated code, source map, and AST.
Transforms the passed in code. Calling a callback with an object with the generated code, source map, and AST.
Here for backward-compatibility. Ideally use transformSync
if you want a synchronous API.
Transforms the passed in code. Calling a callback with an object with the generated code, source map, and AST.
Asynchronously transforms the entire contents of a file.
Asynchronously transforms the entire contents of a file.
Asynchronously transforms the entire contents of a file.
Synchronous version of babel.transformFile
. Returns the transformed contents of the filename
.
Given an AST, transform it.
Given an AST, transform it.
Given an AST, transform it.
Here for backward-compatibility. Ideally use ".transformSync" if you want a synchronous API.
Transforms the passed in code. Returning an object with the generated code, source map, and AST.
Generated using TypeDoc
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.