-
Notifications
You must be signed in to change notification settings - Fork 2
/
jest-resolver.cjs
42 lines (42 loc) · 1.08 KB
/
jest-resolver.cjs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
module.exports = (request, options) => {
return options.defaultResolver(request, {
...options,
packageFilter: (pkg) => {
// When importing snarkyjs, we specify the Node ESM import as Jest by default imports the web version
if (pkg.name === 'snarkyjs') {
return {
...pkg,
main: pkg.exports.node.import,
};
}
if (pkg.name === 'node-fetch') {
return { ...pkg, main: pkg.main };
}
return {
...pkg,
main: pkg.module || pkg.main,
};
},
});
};
module.exports = (request, options) => {
return options.defaultResolver(request, {
...options,
packageFilter: (pkg) => {
// When importing snarkyjs, we specify the Node ESM import as Jest by default imports the web version
if (pkg.name === 'snarkyjs') {
return {
...pkg,
main: pkg.exports.node.import,
};
}
if (pkg.name === 'node-fetch') {
return { ...pkg, main: pkg.main };
}
return {
...pkg,
main: pkg.module || pkg.main,
};
},
});
};