@@ -131,9 +131,16 @@ const resolver = ResolverFactory.createResolver({
131131 extensions: [" .js" , " .json" ],
132132});
133133
134+ // callback
134135resolver .resolve ({}, __dirname , " ./utils" , {}, (err , file ) => {
135136 // ...
136137});
138+
139+ // sync (requires a sync fileSystem)
140+ const fileSync = resolver .resolveSync ({}, __dirname , " ./utils" );
141+
142+ // promise
143+ const filePromise = await resolver .resolvePromise ({}, __dirname , " ./utils" , {});
137144```
138145
139146#### ` CachedInputFileSystem(fileSystem, duration) `
@@ -199,6 +206,8 @@ const context = {};
199206const lookupStartPath = " /Users/webpack/some/root/dir" ;
200207const request = " ./path/to-look-up.js" ;
201208const resolveContext = {};
209+
210+ // callback
202211myResolver .resolve (
203212 context,
204213 lookupStartPath,
@@ -208,6 +217,22 @@ myResolver.resolve(
208217 // Do something with the path
209218 },
210219);
220+
221+ // promise
222+ try {
223+ const filepath = await myResolver .resolvePromise (
224+ context,
225+ lookupStartPath,
226+ request,
227+ resolveContext,
228+ );
229+ // Do something with the path
230+ } catch (err) {
231+ // handle resolve failure
232+ }
233+
234+ // sync (requires a sync fileSystem, e.g. the default Node.js one)
235+ const filepath = myResolver .resolveSync (context, lookupStartPath, request);
211236```
212237
213238#### Resolver Options
0 commit comments