Attach a comment after all non-user injected code
Default: null
Attach a comment before all non-user injected code
Default: null
Specify whether or not to use .babelrc and .babelignore files.
Default: true
Specify which packages should be search for .babelrc files when they are being compiled. true
to always search, or a path string or an array of paths to packages to search
inside of. Defaults to only searching the "root" package.
Default: (root)
Utilities may pass a caller object to identify themselves to Babel and pass capability-related flags for use by configs, presets and plugins.
Enable code generation
Default: true
Output comments in generated output
Default: true
Do not include superfluous whitespace characters and line terminators. When set to "auto"
compact is set to true
on input sizes of >500KB
Default: "auto"
The config file to load Babel's config from. Defaults to searching for "babel.config.js" inside the "root" folder. false
will disable searching for config files.
Default: undefined
The working directory that Babel's programmatic options are loaded relative to.
Default: "."
This is an object of keys that represent different environments. For example, you may have: { env: { production: { \/* specific options *\/ } } }
which will use those options when the envName
is production
Default: {}
Defaults to environment variable BABEL_ENV
if set, or else NODE_ENV
if set, or else it defaults to "development"
Default: env vars
A path to a .babelrc
file to extend
Default: null
Filename for use in errors etc
Default: "unknown"
Filename relative to sourceRoot
Default: (filename)
An object containing the options to be passed down to the babel code generator, @babel/generator
Default: {}
Specify a custom callback to generate a module id with. Called as getModuleId(moduleName)
. If falsy value is returned then the generated module id is used
Default: null
ANSI highlight syntax error code frames
Default: true
Opposite to the only
option. ignore
is disregarded if only
is specified
Default: null
A source map object that the output source map will be based on
Default: null
Should the output be minified (not printing last semicolons in blocks, printing literal string values instead of escaped ones, stripping ()
from new
when safe)
Default: false
Specify a custom name for module ids
Default: null
If truthy, insert an explicit id for modules. By default, all modules are anonymous. (Not available for common
modules)
Default: false
Optional prefix for the AMD module formatter that will be prepend to the filename on module definitions
Default: (sourceRoot)
A glob, regex, or mixed array of both, matching paths to only compile. Can also be an array of arrays containing paths to explicitly match. When attempting to compile a non-matching file it's returned verbatim
Default: null
An object containing the options to be passed down to the babel parser, @babel/parser
Default: {}
List of plugins to load and use
Default: []
List of presets (a set of plugins) to load and use
Default: []
Retain line numbers. This will lead to wacky code but is handy for scenarios where you can't use source maps. (NOTE: This will not retain the columns)
Default: false
Specify the "root" folder that defines the location to search for "babel.config.js", and the default folder to allow .babelrc
files inside of.
Default: "."
This option, combined with the "root" value, defines how Babel chooses its project root. The different modes define different ways that Babel can process the "root" value to get the final project root.
An optional callback that controls whether a comment should be output or not. Called as shouldPrintComment(commentContents)
. NOTE: This overrides the comment
option when used
Default: null
Set sources[0]
on returned source map
Default: (filenameRelative)
If truthy, adds a map
property to returned output. If set to "inline"
, a comment with a sourceMappingURL directive is added to the bottom of the returned code. If set to "both"
then a map
property is returned as well as a source map comment appended. This does not emit sourcemap files by itself!
Default: false
The root from which all sources are relative
Default: (moduleRoot)
Indicate the mode the code should be parsed in. Can be one of "script", "module", or "unambiguous". "unambiguous"
will make Babel attempt to guess, based on the presence of ES6
import
or export
statements. Files with ES6 import
s and export
s are considered "module"
and are otherwise "script"
.
Default: ("module")
An optional callback that can be used to wrap visitor methods. NOTE: This is useful for things like introspection, and not really needed for implementing anything. Called as
wrapPluginVisitorMethod(pluginAlias, visitorType, callback)
.
Include the AST in the returned object
Default:
false