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
The easiest way to create a resolver is to use the `createResolver` function on `ResolveFactory`, along with one of the supplied File System implementations.
| alias |[]| A list of module alias configurations or an object which maps key to value |
53
-
| aliasFields |[]| A list of alias fields in description files |
54
-
| cacheWithContext | true | If unsafe cache is enabled, includes `request.context` in the cache key |
55
-
| descriptionFiles |["package.json"]| A list of description files to read from |
56
-
| enforceExtension | false | Enforce that a extension from extensions must be used |
57
-
| enforceModuleExtension | false | Enforce that a extension from moduleExtensions must be used |
58
-
| extensions |[".js", ".json", ".node"]| A list of extensions which should be tried for files |
59
-
| mainFields |["main"]| A list of main fields in description files |
60
-
| mainFiles |["index"]| A list of main files in directories |
61
-
| modules |["node_modules"]| A list of directories to resolve modules from, can be absolute path or folder name |
62
-
| unsafeCache | false | Use this cache object to unsafely cache the successful requests |
63
-
| plugins |[]| A list of additional resolve plugins which should be applied |
64
-
| symlinks | true | Whether to resolve symlinks to their symlinked location |
65
-
| cachePredicate | function() { return true }; | A function which decides whether a request should be cached or not. An object is passed to the function with `path` and `request` properties. |
66
-
| moduleExtensions |[]| A list of module extensions which should be tried for modules |
67
-
| resolveToContext | false | Resolve to a context instead of a file |
68
-
| fileSystem || The file system which should be used |
69
-
| resolver | undefined | A prepared Resolver to which the plugins are attached |
| alias |[]| A list of module alias configurations or an object which maps key to value |
58
+
| aliasFields |[]| A list of alias fields in description files |
59
+
| cacheWithContext | true | If unsafe cache is enabled, includes `request.context` in the cache key |
60
+
| descriptionFiles |["package.json"]| A list of description files to read from |
61
+
| enforceExtension | false | Enforce that a extension from extensions must be used |
62
+
| extensions |[".js", ".json", ".node"]| A list of extensions which should be tried for files |
63
+
| mainFields |["main"]| A list of main fields in description files |
64
+
| mainFiles |["index"]| A list of main files in directories |
65
+
| modules |["node_modules"]| A list of directories to resolve modules from, can be absolute path or folder name |
66
+
| unsafeCache | false | Use this cache object to unsafely cache the successful requests |
67
+
| plugins |[]| A list of additional resolve plugins which should be applied |
68
+
| symlinks | true | Whether to resolve symlinks to their symlinked location |
69
+
| cachePredicate | function() { return true }; | A function which decides whether a request should be cached or not. An object is passed to the function with `path` and `request` properties. |
70
+
| resolveToContext | false | Resolve to a context instead of a file |
71
+
| fileSystem || The file system which should be used |
72
+
| resolver | undefined | A prepared Resolver to which the plugins are attached |
70
73
71
74
## Plugins
75
+
72
76
Similar to `webpack`, the core of `enhanced-resolve` functionality is implemented as individual plugins that are executed using [`Tapable`](https://github.com/webpack/tapable). These plugins can extend the functionality of the library, adding other ways for files/contexts to be resolved.
73
77
74
78
A plugin should be a `class` (or its ES5 equivalent) with an `apply` method. The `apply` method will receive a `resolver` instance, that can be used to hook in to the event system.
Plugins are executed in a pipeline, and register which event they should be executed before/after. In the example above, `source` is the name of the event that starts the pipeline, and `target` is what event this plugin should fire, which is what continues the execution of the pipeline. For an example of how these different plugin events create a chain, see `lib/ResolverFactory.js`, in the `//// pipeline ////` section.
If you are using `webpack`, and you want to pass custom options to `enhanced-resolve`, the options are passed from the `resolve` key of your webpack configuration e.g.:
0 commit comments