Options for babel transpiling.
babel.transform(code, options);
$ babel --name=value
| Option | Default | Description |
|---|---|---|
filename |
"unknown" |
Filename for use in errors etc. |
filenameRelative |
(filename) |
Filename relative to sourceRoot. |
blacklist |
[] |
Array of transformers to exclude. Run babel --help to see a full list of transformers. |
whitelist |
[] |
Array of transformers to only use. Run babel --help to see a full list of transformers. |
loose |
[] |
Array of transformers to enable loose mode on. |
optional |
[] |
Array of transformers to optionally use. Run babel --help to see a full list of transformers. Optional transformers displayed inside square brackets. |
modules |
"common" |
Which module formatter to use. Run babel --help to see a full list of module formatters. |
sourceMap |
false |
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. |
sourceMapName |
(filenameRelative) |
Set file on returned source map. |
sourceFileName |
(filenameRelative) |
Set sources[0] on returned source map. |
sourceRoot |
(moduleRoot) |
The root from which all sources are relative. |
moduleRoot |
(sourceRoot) |
Optional prefix for the AMD module formatter that will be prepend to the filename on module definitions. |
moduleIds |
false |
If truthy, insert an explicit id for modules. By default, all modules are anonymous. (Not available for common modules) |
comments |
true |
Output comments in generated output. |
keepModuleIdExtensions |
false |
Keep extensions in module ids |
externalHelpers |
false |
Uses a reference to babelHelpers instead of placing helpers at the top of your code. Meant to be used in conjunction with external helpers. |
code |
true |
Enable code generation |
ast |
true |
Include the ÅST in the returned object |
format |
(See Formatting Options) | Formatting options for code generation |
playground |
false |
Enable playground support. |
experimental |
false |
Enable support for experimental ES7 features. |
Usage
babel.transform(code, { format: formattingOptions });
| Option | Default | Description |
|---|---|---|
parentheses |
true |
Preserve parentheses in new expressions that have no arguments |
comments |
true |
Output comments in generated output |
compact |
false |
Do not include superfluous whitespace characters and line terminators |
indent |
{...} |
Indent options |
indent.adjustMultilineComment |
true |
Adjust the indentation of multiline comments to keep asterisks vertically aligned |
indent.style |
' ' |
Indent string |
indent.base |
0 |
Base indent level |