Optional assumptionsOptional astInclude the AST in the returned object
Default: false
Optional auxiliaryAttach a comment after all non-user injected code
Default: null
Optional auxiliaryAttach a comment before all non-user injected code
Default: null
Optional babelrcSpecify whether or not to use .babelrc and .babelignore files.
Default: true
Optional babelrcSpecify 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)
Optional browserslistToggles whether or not browserslist config sources are used, which includes searching for any browserslist files or referencing the browserslist key inside package.json. This is useful for projects that use a browserslist config for files that won't be compiled with Babel.
If a string is specified, it must represent the path of a browserslist configuration file. Relative paths are resolved relative to the configuration file which specifies
this option, or to cwd when it's passed as part of the programmatic options.
Default: true
Optional browserslistThe Browserslist environment to use.
Default: undefined
Optional callerUtilities may pass a caller object to identify themselves to Babel and pass capability-related flags for use by configs, presets and plugins.
Optional cloneBy default babel.transformFromAst will clone the input AST to avoid mutations.
Specifying cloneInputAst: false can improve parsing performance if the input AST is not used elsewhere.
Default: true
Optional codeEnable code generation
Default: true
Optional commentsOutput comments in generated output
Default: true
Optional compactDo not include superfluous whitespace characters and line terminators. When set to "auto" compact is set to true on input sizes of >500KB
Default: "auto"
Optional configThe 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
Optional cwdThe working directory that Babel's programmatic options are loaded relative to.
Default: "."
Optional envThis 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: {}
Optional envDefaults to environment variable BABEL_ENV if set, or else NODE_ENV if set, or else it defaults to "development"
Default: env vars
Optional excludeIf any of patterns match, the current configuration object is considered inactive and is ignored during config processing.
Optional extendsA path to a .babelrc file to extend
Default: null
Optional filenameFilename for use in errors etc
Default: "unknown"
Optional filenameFilename relative to sourceRoot
Default: (filename)
Optional generatorAn object containing the options to be passed down to the babel code generator, @babel/generator
Default: {}
Optional getSpecify 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
Optional highlightANSI highlight syntax error code frames
Default: true
Optional ignoreOpposite to the only option. ignore is disregarded if only is specified
Default: null
Optional includeThis option is a synonym for "test"
Optional inputA source map object that the output source map will be based on
Default: null
Optional minifiedShould 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
Optional moduleSpecify a custom name for module ids
Default: null
Optional moduleIf truthy, insert an explicit id for modules. By default, all modules are anonymous. (Not available for common modules)
Default: false
Optional moduleOptional prefix for the AMD module formatter that will be prepend to the filename on module definitions
Default: (sourceRoot)
Optional onlyA 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
Optional overridesAllows users to provide an array of options that will be merged into the current configuration one at a time. This feature is best used alongside the "test"/"include"/"exclude" options to provide conditions for which an override should apply
Optional parserAn object containing the options to be passed down to the babel parser, @babel/parser
Default: {}
Optional pluginsList of plugins to load and use
Default: []
Optional presetsList of presets (a set of plugins) to load and use
Default: []
Optional retainRetain 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
Optional rootSpecify the "root" folder that defines the location to search for "babel.config.js", and the default folder to allow .babelrc files inside of.
Default: "."
Optional rootThis 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.
Optional shouldAn 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
Optional sourceSet sources[0] on returned source map
Default: (filenameRelative)
Optional sourceIf 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
Optional sourceThe root from which all sources are relative
Default: (moduleRoot)
Optional sourceIndicate 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 imports and exports are considered "module" and are otherwise "script".
Default: ("module")
Optional targetsDescribes the environments you support/target for your project. This can either be a browserslist-compatible query (with caveats)
Default: {}
Optional android?: stringOptional browsers?: string | string[]Optional chrome?: stringOptional deno?: stringOptional edge?: stringOptional electron?: stringOptional esmodules?: booleanOptional firefox?: stringOptional ie?: stringOptional ios?: stringOptional node?: true | "current" | Omit<string, "current">Optional opera?: stringOptional rhino?: stringOptional safari?: "tp" | Omit<string, "tp">Optional samsung?: stringOptional testIf all patterns fail to match, the current configuration object is considered inactive and is ignored during config processing.
Optional wrapAn 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).
Specify which assumptions it can make about your code, to better optimize the compilation result. NOTE: This replaces the various
looseoptions in plugins in favor of top-level options that can apply to multiple plugins