Skip to content

Commit b00bd3c

Browse files
vovkasmcpojer
andauthored
chore: add sample snippet to configure main fields for module resolution algorithm (#15687)
Co-authored-by: Christoph Nakazawa <[email protected]>
1 parent 054fa33 commit b00bd3c

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

website/versioned_docs/version-30.0/Configuration.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1529,6 +1529,19 @@ const config: Config = {
15291529
export default config;
15301530
```
15311531

1532+
Jest's `jest-resolve` relies on `unrs-resolver`. We can pass additional options, for example modifying `mainFields` for resolution. For example, for React Native projects, you might want to use this config:
1533+
1534+
```js
1535+
module.exports = (path, options) => {
1536+
// Call the defaultResolver, so we leverage its cache, error handling, etc.
1537+
return options.defaultResolver(path, {
1538+
...options,
1539+
// See this `unrs-resolver` option: from https://github.com/unrs/unrs-resolver?tab=readme-ov-file#main-field
1540+
mainFields: ['react-native', 'main'],
1541+
});
1542+
};
1543+
```
1544+
15321545
### `restoreMocks` \[boolean]
15331546

15341547
Default: `false`

0 commit comments

Comments
 (0)