You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
/** List of file extensions to search in order. */
1480
1482
extensions?:Array<string>;
1481
1483
/** List of directory names to be looked up for modules recursively. */
@@ -1491,6 +1493,8 @@ type ResolverOptions = {
1491
1493
1492
1494
The `defaultResolver` passed as an option is the Jest default resolver which might be useful when you write your custom one. It takes the same arguments as your custom synchronous one, e.g. `(path, options)` and returns a string or throws.
1493
1495
1496
+
Similarly, the `defaultAsyncResolver` is the default async resolver which takes the same arguments and returns a promise that resolves with a string or rejects with an error.
1497
+
1494
1498
:::
1495
1499
1496
1500
For example, if you want to respect Browserify's [`"browser"` field](https://github.com/browserify/browserify-handbook/blob/master/readme.markdown#browser-field), you can use the following resolver:
@@ -1522,25 +1526,6 @@ const config: Config = {
1522
1526
exportdefaultconfig;
1523
1527
```
1524
1528
1525
-
By combining `defaultResolver` and `packageFilter` we can implement a `package.json` "pre-processor" that allows us to change how the default resolver will resolve modules. For example, imagine we want to use the field `"module"` if it is present, otherwise fallback to `"main"`:
1526
-
1527
-
```js
1528
-
module.exports= (path, options) => {
1529
-
// Call the defaultResolver, so we leverage its cache, error handling, etc.
1530
-
returnoptions.defaultResolver(path, {
1531
-
...options,
1532
-
// Use packageFilter to process parsed `package.json` before the resolution (see https://www.npmjs.com/package/resolve#resolveid-opts-cb)
1533
-
packageFilter:pkg=> {
1534
-
return {
1535
-
...pkg,
1536
-
// Alter the value of `main` before resolving the package
0 commit comments