Home Manual Reference Source
import {BabelHelper} from 'projext/src/services/common/babelHelper.js'
public class | source

BabelHelper

A set of utilities to easily modify a Babel configuration.

Static Method Summary

Static Public Methods
public static

addEnvPresetFeature(configuration: Object, feature: string | Array): Object

Add a required feature to the env preset options (it will go on the include option).

public static

addPlugin(configuration: Object, plugin: string | Array): Object

Adds a plugin or a list of them to a Babel configuration.

public static

addPreset(configuration: Object, preset: string | Array): Object

Adds a preset or a list of them to a Babel configuration.

public static

Disable the env preset modules option as it may cause conflict with some packages.

public static

Update the options of the env preset on a Babel configuration.

Static Public Methods

public static addEnvPresetFeature(configuration: Object, feature: string | Array): Object source

Add a required feature to the env preset options (it will go on the include option).

Params:

NameTypeAttributeDescription
configuration Object

The configuration to update.

feature string | Array

The name of the feature to add or a list of them.

Return:

Object

The updated configuration.

public static addPlugin(configuration: Object, plugin: string | Array): Object source

Adds a plugin or a list of them to a Babel configuration. If the plugins option doesn't exist, the method will create it.

Params:

NameTypeAttributeDescription
configuration Object

The configuration to update.

plugin string | Array

A plugin name or configuration Array ([name, options]), or a list of them.

Return:

Object

The updated configuration.

public static addPreset(configuration: Object, preset: string | Array): Object source

Adds a preset or a list of them to a Babel configuration. If the presets option doesn't exist, the method will create it.

Params:

NameTypeAttributeDescription
configuration Object

The configuration to update.

preset string | Array

A plugin name or configuration Array ([name, options]), or a list of them.

Return:

Object

The updated configuration.

public static disableEnvPresetModules(configuration: Object): Object source

Disable the env preset modules option as it may cause conflict with some packages.

Params:

NameTypeAttributeDescription
configuration Object

The configuration to update.

Return:

Object

The updated configuration.

public static updateEnvPreset(configuration: Object, updateFn: UpdateEnvPresetFunction): Object source

Update the options of the env preset on a Babel configuration. If the presets option doesn't exist, it will create one and add the preset. If presets exists and there's already an env preset, it will update it. But if presets exists but there's no env preset, it won't do anything.

Params:

NameTypeAttributeDescription
configuration Object

The configuration to update.

updateFn UpdateEnvPresetFunction

The function called in order to update the env preset options.

Return:

Object

The updated configuration.