Skip to content

Commit 4ccd12a

Browse files
authored
Fix Docs after breaking change (#15746)
1 parent 22236cf commit 4ccd12a

File tree

1 file changed

+2
-9
lines changed

1 file changed

+2
-9
lines changed

docs/Configuration.md

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1522,21 +1522,14 @@ const config: Config = {
15221522
export default config;
15231523
```
15241524

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"`:
1525+
By passing a `mainFields` option to `defaultResolver` 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"`:
15261526

15271527
```js
15281528
module.exports = (path, options) => {
15291529
// Call the defaultResolver, so we leverage its cache, error handling, etc.
15301530
return options.defaultResolver(path, {
15311531
...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
1537-
main: pkg.module || pkg.main,
1538-
};
1539-
},
1532+
mainFields: ['module', 'main'],
15401533
});
15411534
};
15421535
```

0 commit comments

Comments
 (0)