|
|
- "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,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uL3NyYy9pbmRleC5qcyJdLCJuYW1lcyI6WyJhcnJheU1lcmdlIiwic291cmNlIiwib3ZlcnJpZGVzIiwiU2V0IiwibWVyZ2VBcnJheSIsInJlc29sdmUiLCJkZWVwbWVyZ2VPcHRzIiwicmVkdWNlIiwicmVkdWN0aW9uIiwib3ZlcnJpZGUiLCJvdmVycmlkZU5hbWUiLCJBcnJheSIsImlzQXJyYXkiLCJvdmVycmlkZU9wdGlvbnMiLCJiYXNlIiwiZmluZCIsImJhc2VOYW1lIiwiaW5jbHVkZXMiLCJpbmRleCIsImluZGV4T2YiLCJsZW5ndGgiLCJiYXNlT3B0aW9ucyIsIm9wdGlvbnMiLCJpc01lcmdlYWJsZU9iamVjdCIsInZhbHVlIiwiT2JqZWN0Iiwia2V5cyIsImJhYmVsTWVyZ2UiLCJwbHVnaW5zIiwicmVzb2x2ZVBsdWdpbiIsInByZXNldHMiLCJyZXNvbHZlUHJlc2V0Iiwic291cmNlRW52IiwiZW52Iiwib3ZlcnJpZGVzRW52IiwiYXNzaWduIiwibWVyZ2UiLCJhbGwiLCJtYXAiLCJuYW1lIiwiZ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