Skip to content

Commit

Permalink
docs: mention resolveSync and resolvePathSync utils
Browse files Browse the repository at this point in the history
  • Loading branch information
pi0 committed May 24, 2023
1 parent 5223f5a commit 02a5efe
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions README.md
Expand Up @@ -40,15 +40,15 @@ Several utilities to make ESM resolution easier:
- Supporting custom `conditions`
- Support resolving from multiple paths or urls

### `resolve`
### `resolve` / `resolveSync`

Resolve a module by respecting [ECMAScript Resolver algorithm](https://nodejs.org/dist/latest-v14.x/docs/api/esm.html#esm_resolver_algorithm)
(using [wooorm/import-meta-resolve](https://github.com/wooorm/import-meta-resolve)).

Additionally supports resolving without extension and `/index` similar to CommonJS.

```js
import { resolve } from "mlly";
import { resolve, resolveSync } from "mlly";

// file:///home/user/project/module.mjs
console.log(await resolve("./module.mjs", { url: import.meta.url }));
Expand All @@ -60,12 +60,12 @@ console.log(await resolve("./module.mjs", { url: import.meta.url }));
- `conditions`: Array of conditions used for resolution algorithm (default is `['node', 'import']`)
- `extensions`: Array of additional extensions to check if import failed (default is `['.mjs', '.cjs', '.js', '.json']`)
### `resolvePath`
### `resolvePath` / `resolvePathSync`
Similar to `resolve` but returns a path instead of URL using `fileURLToPath`.
```js
import { resolvePath } from "mlly";
import { resolvePath, resolveSync } from "mlly";

// /home/user/project/module.mjs
console.log(await resolvePath("./module.mjs", { url: import.meta.url }));
Expand Down

0 comments on commit 02a5efe

Please sign in to comment.