Skip to content

Commit e0b5a59

Browse files
Merge pull request #87 from michalkvasnicak/fix/resolve-option-resolver
Fix resolving resolve option
2 parents 8bf7886 + c2c8fe9 commit e0b5a59

File tree

2 files changed

+25
-5
lines changed

2 files changed

+25
-5
lines changed

src/options_resolvers/resolve.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ export default function resolve(value/* , currentConfig */) {
1313
throw new Error(`Configuration 'resolve' is not an object`);
1414
}
1515

16-
if (alias in value && !isPlainObject(value.alias)) {
16+
if ('alias' in value && !isPlainObject(value.alias)) {
1717
throw new Error(`Configuration 'resolve.alias' is not an object`);
1818
}
1919

20-
if (extensions in value) {
20+
if ('extensions' in value) {
2121
if (!Array.isArray(value.extensions)) {
2222
throw new Error(`Configuration 'resolve.extensions' is not an array`);
2323
}
@@ -29,7 +29,7 @@ export default function resolve(value/* , currentConfig */) {
2929
});
3030
}
3131

32-
if (modules in value) {
32+
if ('modules' in value) {
3333
if (!Array.isArray(value.modules)) {
3434
throw new Error(`Configuration 'resolve.modules' is not an array`);
3535
}
@@ -41,11 +41,11 @@ export default function resolve(value/* , currentConfig */) {
4141
});
4242
}
4343

44-
if (mainFile in value && !isString(value.mainFile)) {
44+
if ('mainFile' in value && !isString(value.mainFile)) {
4545
throw new Error(`Configuration 'resolve.mainFile' is not a string`);
4646
}
4747

48-
if (preserveSymlinks in value && !isBoolean(value.preserveSymlinks)) {
48+
if ('preserveSymlinks' in value && !isBoolean(value.preserveSymlinks)) {
4949
throw new Error(`Configuration 'resolve.preserveSymlinks' is not a boolean`);
5050
}
5151

test/options_resolvers/resolve.spec.js

+20
Original file line numberDiff line numberDiff line change
@@ -48,4 +48,24 @@ describe('options_resolvers/resolve', () => {
4848
() => resolve({ preserveSymlinks: 1 })
4949
).to.throw();
5050
});
51+
52+
it('works if resolve.alias is an object', () => {
53+
expect(() => resolve({ alias: {} })).to.not.throw();
54+
});
55+
56+
it('works if resolve.extensions is an array of strings', () => {
57+
expect(() => resolve({ extensions: ['a', 'b'] })).to.not.throw();
58+
});
59+
60+
it('works if resolve.modules is an array of valid file paths', () => {
61+
expect(() => resolve({ modules: [__dirname] })).to.not.throw();
62+
});
63+
64+
it('works if resolve.mainFile is a string', () => {
65+
expect(() => resolve({ mainFile: 'aa' })).to.not.throw();
66+
});
67+
68+
it('works if resolve.preserveSymlinks is a boolean', () => {
69+
expect(() => resolve({ preserveSymlinks: true })).to.not.throw();
70+
});
5171
});

0 commit comments

Comments
 (0)