Skip to content

Commit fd8449b

Browse files
committed
fix: Allow merging a RegExp to itself
Closes #145.
1 parent 17fb00f commit fd8449b

3 files changed

Lines changed: 39 additions & 0 deletions

File tree

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
## 5.1.3 / 2020-08-30
4+
5+
- Fix - Allow merging a `RegExp` to itself #145
6+
37
## 5.1.2 / 2020-08-18
48

59
- Fix - Allow overriding an object field with `null` #144

src/join-arrays.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,17 @@ export default function joinArrays({
1919
if (isFunction(a) && isFunction(b)) {
2020
return (...args: any[]) => _joinArrays(a(...args), b(...args), k);
2121
}
22+
2223
if (isArray(a) && isArray(b)) {
2324
const customResult = customizeArray && customizeArray(a, b, newKey);
2425

2526
return customResult || [...a, ...b];
2627
}
2728

29+
if (isRegex(b)) {
30+
return b;
31+
}
32+
2833
if (isPlainObject(a) && isPlainObject(b)) {
2934
const customResult = customizeObject && customizeObject(a, b, newKey);
3035

@@ -53,6 +58,10 @@ export default function joinArrays({
5358
};
5459
}
5560

61+
function isRegex(o) {
62+
return o instanceof RegExp;
63+
}
64+
5665
// https://stackoverflow.com/a/7356528/228885
5766
function isFunction(functionToCheck) {
5867
return (

test/merge.test.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,32 @@ function normalMergeTest(merge, loadersKey) {
4141
);
4242
});
4343

44+
it("should allow merging optimization config to itself (#145)", function () {
45+
const config = {
46+
optimization: {
47+
runtimeChunk: {
48+
name: "runtime",
49+
},
50+
51+
splitChunks: {
52+
minChunks: 2,
53+
minSize: 30000,
54+
55+
cacheGroups: {
56+
clientApplication: {
57+
name: "clientApplication",
58+
test: /applications\/client/,
59+
chunks: "all",
60+
enforce: true,
61+
},
62+
},
63+
},
64+
},
65+
};
66+
67+
assert.deepEqual(merge(config, config), config);
68+
});
69+
4470
it("should error on promise", function () {
4571
const a = {
4672
module: {},

0 commit comments

Comments
 (0)