|
"use strict";
|
|
|
|
var _object = _interopRequireDefault(require("object.omit"));
|
|
|
|
var _deepmerge = _interopRequireDefault(require("deepmerge"));
|
|
|
|
var _core = require("@babel/core");
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; }
|
|
|
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
|
|
function arrayMerge(source = [], overrides = []) {
|
|
return [...new Set([...source, ...overrides])];
|
|
}
|
|
|
|
function mergeArray(source = [], overrides = [], resolve, deepmergeOpts) {
|
|
return [...source, ...overrides].reduce((reduction, override) => {
|
|
const overrideName = resolve(Array.isArray(override) ? override[0] : override);
|
|
const overrideOptions = Array.isArray(override) ? override[1] : {};
|
|
const base = reduction.find(base => {
|
|
const baseName = resolve(Array.isArray(base) ? base[0] : base);
|
|
return baseName === overrideName || baseName.includes(overrideName);
|
|
});
|
|
const index = reduction.includes(base) ? reduction.indexOf(base) : reduction.length;
|
|
const baseName = base ? resolve(Array.isArray(base) ? base[0] : base) : overrideName;
|
|
const baseOptions = Array.isArray(base) ? base[1] : {};
|
|
const options = (0, _deepmerge.default)(baseOptions, overrideOptions, _objectSpread({
|
|
arrayMerge,
|
|
isMergeableObject: value => Array.isArray(value)
|
|
}, deepmergeOpts));
|
|
reduction[index] = Object.keys(options).length ? [baseName, options] : baseName;
|
|
return reduction;
|
|
}, []);
|
|
}
|
|
|
|
function babelMerge(source = {}, overrides = {}, deepmergeOpts) {
|
|
const plugins = mergeArray(source.plugins, overrides.plugins, _core.resolvePlugin, deepmergeOpts);
|
|
const presets = mergeArray(source.presets, overrides.presets, _core.resolvePreset, deepmergeOpts);
|
|
const sourceEnv = source.env || {};
|
|
const overridesEnv = overrides.env || {};
|
|
return Object.assign(presets.length ? {
|
|
presets
|
|
} : {}, plugins.length ? {
|
|
plugins
|
|
} : {}, _deepmerge.default.all([(0, _object.default)(source, ['plugins', 'presets', 'env']), (0, _object.default)(overrides, ['plugins', 'presets', 'env']), ...[...new Set([...Object.keys(sourceEnv), ...Object.keys(overridesEnv)])].map(name => ({
|
|
env: {
|
|
[name]: babelMerge(sourceEnv[name], overridesEnv[name], deepmergeOpts)
|
|
}
|
|
}))], _objectSpread({
|
|
arrayMerge
|
|
}, deepmergeOpts)));
|
|
}
|
|
|
|
Object.defineProperty(babelMerge, 'all', {
|
|
value: (values = [], deepmergeOpts) => values.reduce((acc, value) => {
|
|
if (value) {
|
|
Object.assign(acc, babelMerge(acc, value, deepmergeOpts));
|
|
}
|
|
|
|
return acc;
|
|
}, {})
|
|
});
|
|
module.exports = babelMerge;
|
|
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uL3NyYy9pbmRleC5qcyJdLCJuYW1lcyI6WyJhcnJheU1lcmdlIiwic291cmNlIiwib3ZlcnJpZGVzIiwiU2V0IiwibWVyZ2VBcnJheSIsInJlc29sdmUiLCJkZWVwbWVyZ2VPcHRzIiwicmVkdWNlIiwicmVkdWN0aW9uIiwib3ZlcnJpZGUiLCJvdmVycmlkZU5hbWUiLCJBcnJheSIsImlzQXJyYXkiLCJvdmVycmlkZU9wdGlvbnMiLCJiYXNlIiwiZmluZCIsImJhc2VOYW1lIiwiaW5jbHVkZXMiLCJpbmRleCIsImluZGV4T2YiLCJsZW5ndGgiLCJiYXNlT3B0aW9ucyIsIm9wdGlvbnMiLCJpc01lcmdlYWJsZU9iamVjdCIsInZhbHVlIiwiT2JqZWN0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