1. modify-babel-preset
Create a modified babel preset based on an an existing preset.
modify-babel-preset
Package: modify-babel-preset
Created by: developit
Last modified: Mon, 20 Jun 2022 03:15:16 GMT
Version: 3.2.1
License: MIT
Downloads: 34,380
Repository: https://github.com/developit/modify-babel-preset

Install

npm install modify-babel-preset
yarn add modify-babel-preset

modify-babel-preset

npm
npm
travis

Create a modified babel preset based on an an existing preset.

Works best with npm 3.

 npm i -S modify-babel-preset

API

A single function that takes an existing preset name and a mapping of plugin modifications to apply to that preset. Make sure you have the preset and any added plugins installed as dependencies.

 newPreset = modifyBabelPreset(
	'existing-preset-name',
	{
		'plugin-name': false,  // remove
		'other-plugin': true,  // add
		'foo': { loose:true }  // add + config
	}
);

Modification keys are babel plugin names (you can exclude the babel-plugin- prefix).

Add/Update Plugins

To add a plugin, pass true, or a configuration object:

 {
	// just add a plugin without config:
	'plugin-name': true,

	// add a plugin and set its config
	'other-plugin': { loose:true }
}

Note: adding a plugin that is already provided by the preset just overwrites its configuration.

Remove Plugins

To remove a plugin, pass false:

 {
	'plugin-name': false
}

Example

Here's a simple preset. Just this index.js and a package.json pointing to it with the preset and plugin installed as dependencies.

 var modifyBabelPreset = require('modify-babel-preset');

// just export the cloned, modified preset config:
module.exports = modifyBabelPreset('es2015', {

	// remove the typeof x==='symbol' transform:
	'transform-es2015-typeof-symbol': false,

	// add the JSX transform:
	'transform-react-jsx': true

});

RELATED POST

10 Must-Know Windows Shortcuts That Will Save You Time

10 Must-Know Windows Shortcuts That Will Save You Time

Arrays vs Linked Lists: Which is Better for Memory Management in Data Structures?

Arrays vs Linked Lists: Which is Better for Memory Management in Data Structures?

Navigating AWS Networking: Essential Hacks for Smooth Operation

Navigating AWS Networking: Essential Hacks for Smooth Operation

Achieving Stunning Visuals with Unity's Global Illumination

Achieving Stunning Visuals with Unity's Global Illumination

Nim's Hidden Gems: Lesser-known Features for Writing Efficient Code

Nim's Hidden Gems: Lesser-known Features for Writing Efficient Code