webpack-merge
Advanced tools
Comparing version 5.10.0 to 6.0.0
@@ -8,3 +8,3 @@ import unique from "./unique"; | ||
}): (a: any, b: any, key: Key) => any; | ||
declare type Rules = { | ||
type Rules = { | ||
[s: string]: CustomizeRule | CustomizeRuleString | Rules; | ||
@@ -11,0 +11,0 @@ }; |
@@ -18,6 +18,10 @@ "use strict"; | ||
}; | ||
var __spreadArray = (this && this.__spreadArray) || function (to, from) { | ||
for (var i = 0, il = from.length, j = to.length; i < il; i++, j++) | ||
to[j] = from[i]; | ||
return to; | ||
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) { | ||
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) { | ||
if (ar || !(i in from)) { | ||
if (!ar) ar = Array.prototype.slice.call(from, 0, i); | ||
ar[i] = from[i]; | ||
} | ||
} | ||
return to.concat(ar || Array.prototype.slice.call(from)); | ||
}; | ||
@@ -27,4 +31,4 @@ var __importDefault = (this && this.__importDefault) || function (mod) { | ||
}; | ||
exports.__esModule = true; | ||
exports.unique = exports.mergeWithRules = exports.mergeWithCustomize = exports["default"] = exports.merge = exports.CustomizeRule = exports.customizeObject = exports.customizeArray = void 0; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.unique = exports.mergeWithRules = exports.mergeWithCustomize = exports.default = exports.merge = exports.CustomizeRule = exports.customizeObject = exports.customizeArray = void 0; | ||
var wildcard_1 = __importDefault(require("wildcard")); | ||
@@ -34,5 +38,5 @@ var merge_with_1 = __importDefault(require("./merge-with")); | ||
var unique_1 = __importDefault(require("./unique")); | ||
exports.unique = unique_1["default"]; | ||
exports.unique = unique_1.default; | ||
var types_1 = require("./types"); | ||
exports.CustomizeRule = types_1.CustomizeRule; | ||
Object.defineProperty(exports, "CustomizeRule", { enumerable: true, get: function () { return types_1.CustomizeRule; } }); | ||
var utils_1 = require("./utils"); | ||
@@ -44,6 +48,6 @@ function merge(firstConfiguration) { | ||
} | ||
return mergeWithCustomize({}).apply(void 0, __spreadArray([firstConfiguration], __read(configurations))); | ||
return mergeWithCustomize({}).apply(void 0, __spreadArray([firstConfiguration], __read(configurations), false)); | ||
} | ||
exports.merge = merge; | ||
exports["default"] = merge; | ||
exports.default = merge; | ||
function mergeWithCustomize(options) { | ||
@@ -55,3 +59,3 @@ return function mergeWithOptions(firstConfiguration) { | ||
} | ||
if (utils_1.isUndefined(firstConfiguration) || configurations.some(utils_1.isUndefined)) { | ||
if ((0, utils_1.isUndefined)(firstConfiguration) || configurations.some(utils_1.isUndefined)) { | ||
throw new TypeError("Merging undefined is not supported"); | ||
@@ -80,7 +84,7 @@ } | ||
} | ||
return merge_with_1["default"](firstConfiguration, join_arrays_1["default"](options)); | ||
return (0, merge_with_1.default)(firstConfiguration, (0, join_arrays_1.default)(options)); | ||
} | ||
return firstConfiguration; | ||
} | ||
return merge_with_1["default"]([firstConfiguration].concat(configurations), join_arrays_1["default"](options)); | ||
return (0, merge_with_1.default)([firstConfiguration].concat(configurations), (0, join_arrays_1.default)(options)); | ||
}; | ||
@@ -91,7 +95,7 @@ } | ||
return function (a, b, key) { | ||
var matchedRule = Object.keys(rules).find(function (rule) { return wildcard_1["default"](rule, key); }) || ""; | ||
var matchedRule = Object.keys(rules).find(function (rule) { return (0, wildcard_1.default)(rule, key); }) || ""; | ||
if (matchedRule) { | ||
switch (rules[matchedRule]) { | ||
case types_1.CustomizeRule.Prepend: | ||
return __spreadArray(__spreadArray([], __read(b)), __read(a)); | ||
return __spreadArray(__spreadArray([], __read(b), false), __read(a), false); | ||
case types_1.CustomizeRule.Replace: | ||
@@ -101,3 +105,3 @@ return b; | ||
default: | ||
return __spreadArray(__spreadArray([], __read(a)), __read(b)); | ||
return __spreadArray(__spreadArray([], __read(a), false), __read(b), false); | ||
} | ||
@@ -118,3 +122,3 @@ } | ||
}); | ||
if (utils_1.isPlainObject(currentRule)) { | ||
if ((0, utils_1.isPlainObject)(currentRule)) { | ||
return mergeWithRule({ currentRule: currentRule, a: a, b: b }); | ||
@@ -126,3 +130,3 @@ } | ||
return undefined; | ||
} | ||
}, | ||
}); | ||
@@ -139,3 +143,3 @@ } | ||
var ret = a.map(function (ao) { | ||
if (!utils_1.isPlainObject(currentRule)) { | ||
if (!(0, utils_1.isPlainObject)(currentRule)) { | ||
return ao; | ||
@@ -156,3 +160,5 @@ } | ||
var bMatches = b.filter(function (o) { | ||
var matches = rulesToMatch.every(function (rule) { return utils_1.isSameCondition(ao[rule], o[rule]); }); | ||
var matches = rulesToMatch.every(function (rule) { | ||
return (0, utils_1.isSameCondition)(ao[rule], o[rule]); | ||
}); | ||
if (matches) { | ||
@@ -163,3 +169,3 @@ bAllMatches.push(o); | ||
}); | ||
if (!utils_1.isPlainObject(ao)) { | ||
if (!(0, utils_1.isPlainObject)(ao)) { | ||
return ao; | ||
@@ -200,3 +206,3 @@ } | ||
var lastValue = last(bMatches)[k]; | ||
if (!utils_1.isPlainObject(v) || !utils_1.isPlainObject(lastValue)) { | ||
if (!(0, utils_1.isPlainObject)(v) || !(0, utils_1.isPlainObject)(lastValue)) { | ||
throw new TypeError("Trying to merge non-objects"); | ||
@@ -227,3 +233,3 @@ } | ||
.reduce(function (acc, val) { | ||
return isArray(acc) && isArray(val) ? __spreadArray(__spreadArray([], __read(acc)), __read(val)) : acc; | ||
return isArray(acc) && isArray(val) ? __spreadArray(__spreadArray([], __read(acc), false), __read(val), false) : acc; | ||
}, []); | ||
@@ -258,7 +264,7 @@ ret[k] = mergeWithRule({ currentRule: currentRule_1, a: v, b: b_1 }); | ||
case types_1.CustomizeRule.Prepend: | ||
return merge_with_1["default"]([b, a], join_arrays_1["default"]()); | ||
return (0, merge_with_1.default)([b, a], (0, join_arrays_1.default)()); | ||
case types_1.CustomizeRule.Replace: | ||
return b; | ||
case types_1.CustomizeRule.Append: | ||
return merge_with_1["default"]([a, b], join_arrays_1["default"]()); | ||
return (0, merge_with_1.default)([a, b], (0, join_arrays_1.default)()); | ||
} | ||
@@ -265,0 +271,0 @@ }; |
@@ -18,6 +18,10 @@ "use strict"; | ||
}; | ||
var __spreadArray = (this && this.__spreadArray) || function (to, from) { | ||
for (var i = 0, il = from.length, j = to.length; i < il; i++, j++) | ||
to[j] = from[i]; | ||
return to; | ||
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) { | ||
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) { | ||
if (ar || !(i in from)) { | ||
if (!ar) ar = Array.prototype.slice.call(from, 0, i); | ||
ar[i] = from[i]; | ||
} | ||
} | ||
return to.concat(ar || Array.prototype.slice.call(from)); | ||
}; | ||
@@ -27,4 +31,3 @@ var __importDefault = (this && this.__importDefault) || function (mod) { | ||
}; | ||
exports.__esModule = true; | ||
var clone_deep_1 = __importDefault(require("clone-deep")); | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var merge_with_1 = __importDefault(require("./merge-with")); | ||
@@ -36,4 +39,4 @@ var utils_1 = require("./utils"); | ||
return function _joinArrays(a, b, k) { | ||
var newKey = key ? key + "." + k : k; | ||
if (utils_1.isFunction(a) && utils_1.isFunction(b)) { | ||
var newKey = key ? "".concat(key, ".").concat(k) : k; | ||
if ((0, utils_1.isFunction)(a) && (0, utils_1.isFunction)(b)) { | ||
return function () { | ||
@@ -44,3 +47,3 @@ var args = []; | ||
} | ||
return _joinArrays(a.apply(void 0, __spreadArray([], __read(args))), b.apply(void 0, __spreadArray([], __read(args))), k); | ||
return _joinArrays(a.apply(void 0, __spreadArray([], __read(args), false)), b.apply(void 0, __spreadArray([], __read(args), false)), k); | ||
}; | ||
@@ -50,21 +53,21 @@ } | ||
var customResult = customizeArray && customizeArray(a, b, newKey); | ||
return customResult || __spreadArray(__spreadArray([], __read(a)), __read(b)); | ||
return customResult || __spreadArray(__spreadArray([], __read(a), false), __read(b), false); | ||
} | ||
if (utils_1.isRegex(b)) { | ||
if ((0, utils_1.isRegex)(b)) { | ||
return b; | ||
} | ||
if (utils_1.isPlainObject(a) && utils_1.isPlainObject(b)) { | ||
if ((0, utils_1.isPlainObject)(a) && (0, utils_1.isPlainObject)(b)) { | ||
var customResult = customizeObject && customizeObject(a, b, newKey); | ||
return (customResult || | ||
merge_with_1["default"]([a, b], joinArrays({ | ||
(0, merge_with_1.default)([a, b], joinArrays({ | ||
customizeArray: customizeArray, | ||
customizeObject: customizeObject, | ||
key: newKey | ||
key: newKey, | ||
}))); | ||
} | ||
if (utils_1.isPlainObject(b)) { | ||
return clone_deep_1["default"](b); | ||
if ((0, utils_1.isPlainObject)(b)) { | ||
return structuredClone(b); | ||
} | ||
if (isArray(b)) { | ||
return __spreadArray([], __read(b)); | ||
return __spreadArray([], __read(b), false); | ||
} | ||
@@ -74,3 +77,3 @@ return b; | ||
} | ||
exports["default"] = joinArrays; | ||
exports.default = joinArrays; | ||
//# sourceMappingURL=join-arrays.js.map |
@@ -18,3 +18,3 @@ "use strict"; | ||
}; | ||
exports.__esModule = true; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
function mergeWith(objects, customizer) { | ||
@@ -38,3 +38,3 @@ var _a = __read(objects), first = _a[0], rest = _a.slice(1); | ||
} | ||
exports["default"] = mergeWith; | ||
exports.default = mergeWith; | ||
//# sourceMappingURL=merge-with.js.map |
@@ -1,3 +0,3 @@ | ||
export declare type Key = string; | ||
export declare type Customize = (a: any, b: any, key: Key) => any; | ||
export type Key = string; | ||
export type Customize = (a: any, b: any, key: Key) => any; | ||
export interface ICustomizeOptions { | ||
@@ -14,2 +14,2 @@ customizeArray?: Customize; | ||
} | ||
export declare type CustomizeRuleString = "match" | "merge" | "append" | "prepend" | "replace"; | ||
export type CustomizeRuleString = "match" | "merge" | "append" | "prepend" | "replace"; |
"use strict"; | ||
exports.__esModule = true; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.CustomizeRule = void 0; | ||
@@ -11,3 +11,3 @@ var CustomizeRule; | ||
CustomizeRule["Replace"] = "replace"; | ||
})(CustomizeRule = exports.CustomizeRule || (exports.CustomizeRule = {})); | ||
})(CustomizeRule || (exports.CustomizeRule = CustomizeRule = {})); | ||
//# sourceMappingURL=types.js.map |
@@ -18,25 +18,33 @@ "use strict"; | ||
}; | ||
var __spreadArray = (this && this.__spreadArray) || function (to, from) { | ||
for (var i = 0, il = from.length, j = to.length; i < il; i++, j++) | ||
to[j] = from[i]; | ||
return to; | ||
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) { | ||
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) { | ||
if (ar || !(i in from)) { | ||
if (!ar) ar = Array.prototype.slice.call(from, 0, i); | ||
ar[i] = from[i]; | ||
} | ||
} | ||
return to.concat(ar || Array.prototype.slice.call(from)); | ||
}; | ||
exports.__esModule = true; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
function mergeUnique(key, uniques, getter) { | ||
var uniquesSet = new Set(uniques); | ||
return function (a, b, k) { | ||
return (k === key) && Array.from(__spreadArray(__spreadArray([], __read(a)), __read(b)).map(function (it) { return ({ key: getter(it), value: it }); }) | ||
.map(function (_a) { | ||
var key = _a.key, value = _a.value; | ||
return ({ key: (uniquesSet.has(key) ? key : value), value: value }); | ||
}) | ||
.reduce(function (m, _a) { | ||
var key = _a.key, value = _a.value; | ||
m["delete"](key); // This is required to preserve backward compatible order of elements after a merge. | ||
return m.set(key, value); | ||
}, new Map()) | ||
.values()); | ||
return k === key && | ||
Array.from(__spreadArray(__spreadArray([], __read(a), false), __read(b), false).map(function (it) { return ({ key: getter(it), value: it }); }) | ||
.map(function (_a) { | ||
var key = _a.key, value = _a.value; | ||
return ({ | ||
key: uniquesSet.has(key) ? key : value, | ||
value: value, | ||
}); | ||
}) | ||
.reduce(function (m, _a) { | ||
var key = _a.key, value = _a.value; | ||
m.delete(key); // This is required to preserve backward compatible order of elements after a merge. | ||
return m.set(key, value); | ||
}, new Map()) | ||
.values()); | ||
}; | ||
} | ||
exports["default"] = mergeUnique; | ||
exports.default = mergeUnique; | ||
//# sourceMappingURL=unique.js.map |
@@ -18,3 +18,3 @@ "use strict"; | ||
}; | ||
exports.__esModule = true; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.isSameCondition = exports.isUndefined = exports.isPlainObject = exports.isFunction = exports.isRegex = void 0; | ||
@@ -58,9 +58,12 @@ var flat_1 = require("flat"); | ||
} | ||
if (typeof a === 'string' || typeof b === 'string' || | ||
isRegex(a) || isRegex(b) || | ||
isFunction(a) || isFunction(b)) { | ||
if (typeof a === "string" || | ||
typeof b === "string" || | ||
isRegex(a) || | ||
isRegex(b) || | ||
isFunction(a) || | ||
isFunction(b)) { | ||
return a.toString() === b.toString(); | ||
} | ||
var entriesA = Object.entries(flat_1.flatten(a)); | ||
var entriesB = Object.entries(flat_1.flatten(b)); | ||
var entriesA = Object.entries((0, flat_1.flatten)(a)); | ||
var entriesB = Object.entries((0, flat_1.flatten)(b)); | ||
if (entriesA.length !== entriesB.length) { | ||
@@ -86,3 +89,2 @@ return false; | ||
} | ||
; | ||
entriesA.sort(cmp); | ||
@@ -94,3 +96,4 @@ entriesB.sort(cmp); | ||
for (var i = 0; i < entriesA.length; i++) { | ||
if (entriesA[i][0] !== entriesB[i][0] || ((_a = entriesA[i][1]) === null || _a === void 0 ? void 0 : _a.toString()) !== ((_b = entriesB[i][1]) === null || _b === void 0 ? void 0 : _b.toString())) { | ||
if (entriesA[i][0] !== entriesB[i][0] || | ||
((_a = entriesA[i][1]) === null || _a === void 0 ? void 0 : _a.toString()) !== ((_b = entriesB[i][1]) === null || _b === void 0 ? void 0 : _b.toString())) { | ||
return false; | ||
@@ -97,0 +100,0 @@ } |
@@ -5,8 +5,8 @@ { | ||
"author": "Juho Vepsalainen <bebraw@gmail.com>", | ||
"version": "5.10.0", | ||
"version": "6.0.0", | ||
"scripts": { | ||
"build": "tsc", | ||
"format": "prettier . --write --ignore-path .gitignore", | ||
"start": "tsdx watch", | ||
"test": "tsdx test", | ||
"start": "dts watch", | ||
"test": "dts test", | ||
"prepare": "npm run build" | ||
@@ -20,15 +20,14 @@ }, | ||
"dependencies": { | ||
"clone-deep": "^4.0.1", | ||
"flat": "^5.0.2", | ||
"wildcard": "^2.0.0" | ||
"wildcard": "^2.0.1" | ||
}, | ||
"devDependencies": { | ||
"@types/estree": "0.0.48", | ||
"@types/estree": "1.0.2", | ||
"@types/flat": "^5.0.3", | ||
"dts-cli": "^2.0.3", | ||
"husky": "^6.0.0", | ||
"prettier": "^2.3.1", | ||
"tsdx": "^0.14.1", | ||
"tslib": "^2.2.0", | ||
"typescript": "^4.3.2", | ||
"webpack": "^5.38.1" | ||
"prettier": "^3.0.3", | ||
"tslib": "^2.6.2", | ||
"typescript": "^5.2.2", | ||
"webpack": "^5.89.0" | ||
}, | ||
@@ -48,3 +47,3 @@ "repository": { | ||
"engines": { | ||
"node": ">=10.0.0" | ||
"node": ">=18.0.0" | ||
}, | ||
@@ -51,0 +50,0 @@ "jest": { |
@@ -162,3 +162,3 @@ [![Financial Contributors on Open Collective](https://opencollective.com/webpack-merge/all/badge.svg?label=financial+contributors)](https://opencollective.com/webpack-merge) [![Test](https://github.com/survivejs/webpack-merge/actions/workflows/test.yml/badge.svg?branch=develop&event=push)](https://github.com/survivejs/webpack-merge/actions/workflows/test.yml) [![codecov](https://codecov.io/gh/survivejs/webpack-merge/branch/master/graph/badge.svg)](https://codecov.io/gh/survivejs/webpack-merge) | ||
["HotModuleReplacementPlugin"], | ||
(plugin) => plugin.constructor && plugin.constructor.name | ||
(plugin) => plugin.constructor && plugin.constructor.name, | ||
), | ||
@@ -171,3 +171,3 @@ })( | ||
plugins: [new webpack.HotModuleReplacementPlugin()], | ||
} | ||
}, | ||
); | ||
@@ -242,3 +242,3 @@ | ||
})(a, b), | ||
result | ||
result, | ||
); | ||
@@ -245,0 +245,0 @@ ``` |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
49108
2
581
- Removedclone-deep@^4.0.1
- Removedclone-deep@4.0.1(transitive)
- Removedis-plain-object@2.0.4(transitive)
- Removedisobject@3.0.1(transitive)
- Removedkind-of@6.0.3(transitive)
- Removedshallow-clone@3.0.1(transitive)
Updatedwildcard@^2.0.1