
Security News
Browserslist-rs Gets Major Refactor, Cutting Binary Size by Over 1MB
Browserslist-rs now uses static data to reduce binary size by over 1MB, improving memory use and performance for Rust-based frontend tools.
babel-merge
Advanced tools
`babel-merge` merges multiple Babel configuration objects into a single copy. Plugin and preset objects and arrays will be merged together.
babel-merge
merges multiple Babel configuration objects into a single copy.
Plugin and preset objects and arrays will be merged together.
Note: options to plugins and presets will not be merged, but instead replaced by the last matching item's options. This makes the behavior consistent with how Babel works.
babel-merge
can be installed via the Yarn or npm clients.
❯ yarn add babel-merge
❯ npm install --save babel-merge
Where a
, b
, z
are Babel configuration objects and options
is a deepmerge options object.
const merge = require('babel-merge');
const together = merge(
{
presets: [
['@babel/preset-env', {
targets: {
browsers: ['latest 1 Chrome']
}
}]
]
},
{
presets: [
['@babel/preset-env', {
targets: {
browsers: ['latest 1 Firefox']
}
}]
]
}
)
console.log(together);
{
presets: [
['@babel/preset-env', {
targets: {
browsers: [
'latest 1 Firefox'
]
}
}]
]
}
If a pathname was used in an earlier merge, you can still merge by exact name:
const merge = require('babel-merge');
const together = merge(
{
presets: [
[require.resolve('@babel/preset-env'), {
targets: {
browsers: ['latest 1 Chrome']
}
}]
]
},
{
presets: [
['@babel/preset-env', {
targets: {
browsers: ['latest 1 Firefox']
}
}]
]
}
)
console.log(together);
{
presets: [
['/Users/me/code/app/node_modules/@babel/preset-env/lib/index.js', {
targets: {
browsers: [
'latest 1 Firefox'
]
}
}]
]
}
Even works for plugins and presets within environments:
const merge = require('babel-merge');
const together = merge(
{
env: {
development: {
presets: [
[require.resolve('@babel/preset-env'), {
targets: {
browsers: ['latest 1 Chrome']
}
}]
]
}
}
},
{
env: {
development: {
presets: [
['@babel/preset-env', {
targets: {
browsers: ['latest 1 Firefox']
}
}]
]
}
}
}
)
console.log(together);
{
env: {
development: {
presets: [
['/Users/me/code/app/node_modules/@babel/preset-env/lib/index.js', {
targets: {
browsers: [
'latest 1 Firefox'
]
}
}]
]
}
}
}
Order is preserved between non-option plugins and presets and ones with options:
const merge = require('babel-merge');
const together = merge(
{
plugins: [
'module:fast-async',
'@babel/plugin-syntax-dynamic-import'
]
},
{
plugins: [
'@babel/plugin-proposal-object-rest-spread',
['module:fast-async', { spec: true }],
'@babel/plugin-proposal-class-properties'
]
}
)
console.log(together);
{
plugins: [
['module:fast-async', { spec: true }],
'@babel/plugin-syntax-dynamic-import',
'@babel/plugin-proposal-object-rest-spread',
'@babel/plugin-proposal-class-properties'
]
}
FAQs
`babel-merge` merges multiple Babel configuration objects into a single copy. Plugin and preset objects and arrays will be merged together.
The npm package babel-merge receives a total of 295,534 weekly downloads. As such, babel-merge popularity was classified as popular.
We found that babel-merge demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 4 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Browserslist-rs now uses static data to reduce binary size by over 1MB, improving memory use and performance for Rust-based frontend tools.
Research
Security News
Eight new malicious Firefox extensions impersonate games, steal OAuth tokens, hijack sessions, and exploit browser permissions to spy on users.
Security News
The official Go SDK for the Model Context Protocol is in development, with a stable, production-ready release expected by August 2025.