Skip to content
This repository has been archived by the owner on Feb 18, 2024. It is now read-only.

Commit

Permalink
fix: handle rule.merge({ resolve })
Browse files Browse the repository at this point in the history
  • Loading branch information
cyjake committed Jun 30, 2020
1 parent 1295efa commit 7287fdb
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/Rule.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,10 @@ const Rule = Orderable(
);
}

if (!omit.includes('resolve') && 'resolve' in obj) {
this.resolve.merge(obj.resolve);
}

if (!omit.includes('test') && 'test' in obj) {
this.test(
obj.test instanceof RegExp || typeof obj.test === 'function'
Expand All @@ -127,6 +131,7 @@ const Rule = Orderable(
'use',
'rules',
'oneOf',
'resolve',
'test',
]);
}
Expand Down
23 changes: 23 additions & 0 deletions test/Rule.js
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,29 @@ test('merge with include and exclude not of array type', () => {
});
});

test('merge with resolve', () => {
const rule = new Rule();

rule.merge({
resolve: {
alias: { foo: 'bar' },
},
});

rule.merge({
resolve: {
extensions: ['.js', '.mjs'],
}
})

expect(rule.toConfig()).toStrictEqual({
resolve: {
alias: { foo: 'bar' },
extensions: ['.js', '.mjs'],
},
});
});

test('ordered rules', () => {
const rule = new Rule();
rule
Expand Down

0 comments on commit 7287fdb

Please sign in to comment.