Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface TransformOptions

Hierarchy

  • TransformOptions

Index

Properties

Optional ast

ast: boolean | null

Include the AST in the returned object

Default: false

Optional auxiliaryCommentAfter

auxiliaryCommentAfter: string | null

Attach a comment after all non-user injected code

Default: null

Optional auxiliaryCommentBefore

auxiliaryCommentBefore: string | null

Attach a comment before all non-user injected code

Default: null

Optional babelrc

babelrc: boolean | null

Specify whether or not to use .babelrc and .babelignore files.

Default: true

Optional babelrcRoots

babelrcRoots: true | string | string[] | null

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)

Optional caller

Utilities may pass a caller object to identify themselves to Babel and pass capability-related flags for use by configs, presets and plugins.

see

https://babeljs.io/docs/en/next/options#caller

Optional code

code: boolean | null

Enable code generation

Default: true

Optional comments

comments: boolean | null

Output comments in generated output

Default: true

Optional compact

compact: boolean | "auto" | null

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"

Optional configFile

configFile: string | false | null

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

Optional cwd

cwd: string | null

The working directory that Babel's programmatic options are loaded relative to.

Default: "."

Optional env

env: {} | null

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: {}

Optional envName

envName: undefined | string

Defaults to environment variable BABEL_ENV if set, or else NODE_ENV if set, or else it defaults to "development"

Default: env vars

Optional extends

extends: string | null

A path to a .babelrc file to extend

Default: null

Optional filename

filename: string | null

Filename for use in errors etc

Default: "unknown"

Optional filenameRelative

filenameRelative: string | null

Filename relative to sourceRoot

Default: (filename)

Optional generatorOpts

generatorOpts: GeneratorOptions | null

An object containing the options to be passed down to the babel code generator, @babel/generator

Default: {}

Optional getModuleId

getModuleId: ((moduleName: string) => string | null | undefined) | null

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

Optional highlightCode

highlightCode: boolean | null

ANSI highlight syntax error code frames

Default: true

Optional ignore

ignore: string[] | null

Opposite to the only option. ignore is disregarded if only is specified

Default: null

Optional inputSourceMap

inputSourceMap: object | null

A source map object that the output source map will be based on

Default: null

Optional minified

minified: boolean | 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

Optional moduleId

moduleId: string | null

Specify a custom name for module ids

Default: null

Optional moduleIds

moduleIds: boolean | null

If truthy, insert an explicit id for modules. By default, all modules are anonymous. (Not available for common modules)

Default: false

Optional moduleRoot

moduleRoot: string | null

Optional prefix for the AMD module formatter that will be prepend to the filename on module definitions

Default: (sourceRoot)

Optional only

only: string | RegExp | Array<string | RegExp> | null

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

Optional parserOpts

parserOpts: ParserOptions | null

An object containing the options to be passed down to the babel parser, @babel/parser

Default: {}

Optional plugins

plugins: PluginItem[] | null

List of plugins to load and use

Default: []

Optional presets

presets: PluginItem[] | null

List of presets (a set of plugins) to load and use

Default: []

Optional retainLines

retainLines: boolean | null

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

Optional root

root: string | null

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: "."

Optional rootMode

rootMode: "root" | "upward" | "upward-optional"

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.

see

https://babeljs.io/docs/en/next/options#rootmode

Optional shouldPrintComment

shouldPrintComment: ((commentContents: string) => boolean) | null

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

Optional sourceFileName

sourceFileName: string | null

Set sources[0] on returned source map

Default: (filenameRelative)

Optional sourceMaps

sourceMaps: boolean | "inline" | "both" | null

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

Optional sourceRoot

sourceRoot: string | null

The root from which all sources are relative

Default: (moduleRoot)

Optional sourceType

sourceType: "script" | "module" | "unambiguous" | null

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 imports and exports are considered "module" and are otherwise "script".

Default: ("module")

Optional wrapPluginVisitorMethod

wrapPluginVisitorMethod: ((pluginAlias: string, visitorType: "enter" | "exit", callback: (path: NodePath, state: any) => void) => (path: NodePath, state: any) => void) | null

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).