webpack-merge
Advanced tools
Comparing version
@@ -145,3 +145,3 @@ "use strict"; | ||
var bMatches = b.filter(function (o) { | ||
var matches = rulesToMatch.every(function (rule) { var _a, _b; return ((_a = ao[rule]) === null || _a === void 0 ? void 0 : _a.toString()) === ((_b = o[rule]) === null || _b === void 0 ? void 0 : _b.toString()); }); | ||
var matches = rulesToMatch.every(function (rule) { return utils_1.isSameCondition(ao[rule], o[rule]); }); | ||
if (matches) { | ||
@@ -148,0 +148,0 @@ bAllMatches.push(o); |
@@ -5,2 +5,14 @@ declare function isRegex(o: any): boolean; | ||
declare function isUndefined(a: any): boolean; | ||
export { isRegex, isFunction, isPlainObject, isUndefined }; | ||
/** | ||
* According to Webpack docs, a "test" should be the following: | ||
* | ||
* - A string | ||
* - A RegExp | ||
* - A function | ||
* - An array of conditions (may be nested) | ||
* - An object of conditions (may be nested) | ||
* | ||
* https://webpack.js.org/configuration/module/#condition | ||
*/ | ||
declare function isSameCondition(a: any, b: any): boolean; | ||
export { isRegex, isFunction, isPlainObject, isUndefined, isSameCondition }; |
"use strict"; | ||
var __read = (this && this.__read) || function (o, n) { | ||
var m = typeof Symbol === "function" && o[Symbol.iterator]; | ||
if (!m) return o; | ||
var i = m.call(o), r, ar = [], e; | ||
try { | ||
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); | ||
} | ||
catch (error) { e = { error: error }; } | ||
finally { | ||
try { | ||
if (r && !r.done && (m = i["return"])) m.call(i); | ||
} | ||
finally { if (e) throw e.error; } | ||
} | ||
return ar; | ||
}; | ||
exports.__esModule = true; | ||
exports.isUndefined = exports.isPlainObject = exports.isFunction = exports.isRegex = void 0; | ||
exports.isSameCondition = exports.isUndefined = exports.isPlainObject = exports.isFunction = exports.isRegex = void 0; | ||
var flat_1 = require("flat"); | ||
function isRegex(o) { | ||
@@ -24,2 +41,59 @@ return o instanceof RegExp; | ||
exports.isUndefined = isUndefined; | ||
/** | ||
* According to Webpack docs, a "test" should be the following: | ||
* | ||
* - A string | ||
* - A RegExp | ||
* - A function | ||
* - An array of conditions (may be nested) | ||
* - An object of conditions (may be nested) | ||
* | ||
* https://webpack.js.org/configuration/module/#condition | ||
*/ | ||
function isSameCondition(a, b) { | ||
var _a, _b; | ||
if (!a || !b) { | ||
return a === 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)); | ||
if (entriesA.length !== entriesB.length) { | ||
return false; | ||
} | ||
for (var i = 0; i < entriesA.length; i++) { | ||
entriesA[i][0] = entriesA[i][0].replace(/\b\d+\b/g, "[]"); | ||
entriesB[i][0] = entriesB[i][0].replace(/\b\d+\b/g, "[]"); | ||
} | ||
function cmp(_a, _b) { | ||
var _c = __read(_a, 2), k1 = _c[0], v1 = _c[1]; | ||
var _d = __read(_b, 2), k2 = _d[0], v2 = _d[1]; | ||
if (k1 < k2) | ||
return -1; | ||
if (k1 > k2) | ||
return 1; | ||
if (v1 < v2) | ||
return -1; | ||
if (v1 > v2) | ||
return 1; | ||
return 0; | ||
} | ||
; | ||
entriesA.sort(cmp); | ||
entriesB.sort(cmp); | ||
if (entriesA.length !== entriesB.length) { | ||
return false; | ||
} | ||
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())) { | ||
return false; | ||
} | ||
} | ||
return true; | ||
} | ||
exports.isSameCondition = isSameCondition; | ||
//# sourceMappingURL=utils.js.map |
@@ -5,3 +5,3 @@ { | ||
"author": "Juho Vepsalainen <bebraw@gmail.com>", | ||
"version": "5.9.0", | ||
"version": "5.10.0", | ||
"scripts": { | ||
@@ -21,2 +21,3 @@ "build": "tsc", | ||
"clone-deep": "^4.0.1", | ||
"flat": "^5.0.2", | ||
"wildcard": "^2.0.0" | ||
@@ -26,2 +27,3 @@ }, | ||
"@types/estree": "0.0.48", | ||
"@types/flat": "^5.0.3", | ||
"husky": "^6.0.0", | ||
@@ -28,0 +30,0 @@ "prettier": "^2.3.1", |
@@ -1,2 +0,2 @@ | ||
[](https://opencollective.com/webpack-merge) [](http://travis-ci.org/survivejs/webpack-merge) [](https://codecov.io/gh/survivejs/webpack-merge) | ||
[](https://opencollective.com/webpack-merge) [](https://github.com/survivejs/webpack-merge/actions/workflows/test.yml) [](https://codecov.io/gh/survivejs/webpack-merge) | ||
@@ -3,0 +3,0 @@ # webpack-merge - Merge designed for Webpack |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
47918
10.25%561
18.11%3
50%8
14.29%+ Added
+ Added