@@ -40,15 +40,15 @@ Several utilities to make ESM resolution easier:
40
40
- Supporting custom ` conditions `
41
41
- Support resolving from multiple paths or urls
42
42
43
- ### ` resolve `
43
+ ### ` resolve ` / ` resolveSync `
44
44
45
45
Resolve a module by respecting [ ECMAScript Resolver algorithm] ( https://nodejs.org/dist/latest-v14.x/docs/api/esm.html#esm_resolver_algorithm )
46
46
(using [ wooorm/import-meta-resolve] ( https://github.com/wooorm/import-meta-resolve ) ).
47
47
48
48
Additionally supports resolving without extension and ` /index ` similar to CommonJS.
49
49
50
50
``` js
51
- import { resolve } from " mlly" ;
51
+ import { resolve , resolveSync } from " mlly" ;
52
52
53
53
// file:///home/user/project/module.mjs
54
54
console .log (await resolve (" ./module.mjs" , { url: import .meta.url }));
@@ -60,12 +60,12 @@ console.log(await resolve("./module.mjs", { url: import.meta.url }));
60
60
- ` conditions` : Array of conditions used for resolution algorithm (default is ` [' node' , ' import' ]` )
61
61
- ` extensions` : Array of additional extensions to check if import failed (default is ` [' .mjs' , ' .cjs' , ' .js' , ' .json' ]` )
62
62
63
- ### ` resolvePath`
63
+ ### ` resolvePath` / ` resolvePathSync `
64
64
65
65
Similar to ` resolve` but returns a path instead of URL using ` fileURLToPath` .
66
66
67
67
` ` ` js
68
- import { resolvePath } from " mlly" ;
68
+ import { resolvePath , resolveSync } from " mlly" ;
69
69
70
70
// /home/user/project/module.mjs
71
71
console .log (await resolvePath (" ./module.mjs" , { url: import .meta.url }));
0 commit comments