-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathjest.resolver.js
More file actions
32 lines (30 loc) · 925 Bytes
/
Copy pathjest.resolver.js
File metadata and controls
32 lines (30 loc) · 925 Bytes
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
/**
* Combines the React Native jest resolver (packageFilter workaround) with the
* react-native-worklets resolver, which must resolve its non-native (jest-safe)
* module variants so importing reanimated does not touch native TurboModules.
*/
'use strict';
module.exports = (request, options) => {
if (
options.basedir.includes('react-native-worklets') ||
request.includes('react-native-worklets')
) {
options = {
...options,
extensions: options.extensions?.filter((ext) => !ext.includes('native')),
};
}
const originalPackageFilter = options.packageFilter;
return options.defaultResolver(request, {
...options,
packageFilter: (pkg) => {
const filteredPkg = originalPackageFilter
? originalPackageFilter(pkg)
: pkg;
if (filteredPkg.name === 'react-native') {
delete filteredPkg.exports;
}
return filteredPkg;
},
});
};