@@ -31,13 +31,13 @@ import maps, export maps, loading CJS and ESM projects, all of that!
3131
3232## When to use this?
3333
34- As of Node.js 19.3 , ` import.meta.resolve ` is still behind an experimental flag.
35- This package can be used to do what it does in Node 14–19 .
34+ As of Node.js 20.0 , ` import.meta.resolve ` is still behind an experimental flag.
35+ This package can be used to do what it does in Node 14–20 .
3636
3737## Install
3838
3939This package is [ ESM only] [ esm ] .
40- In Node.js (version 14.14+ and 16 .0+), install with [ npm] [ ] :
40+ In Node.js (version 18 .0+), install with [ npm] [ ] :
4141
4242``` sh
4343npm install import-meta-resolve
@@ -49,30 +49,30 @@ npm install import-meta-resolve
4949import {resolve } from ' import-meta-resolve'
5050
5151// A file:
52- console .log (await resolve (' ./index.js' , import .meta.url))
52+ console .log (resolve (' ./index.js' , import .meta.url))
5353// => file:///Users/tilde/Projects/oss/import-meta-resolve/index.js
5454
5555// A CJS package:
56- console .log (await resolve (' builtins' , import .meta.url))
56+ console .log (resolve (' builtins' , import .meta.url))
5757// => file:///Users/tilde/Projects/oss/import-meta-resolve/node_modules/builtins/index.js
5858
5959// A scoped CJS package:
60- console .log (await resolve (' @eslint/eslintrc' , import .meta.url))
60+ console .log (resolve (' @eslint/eslintrc' , import .meta.url))
6161// => file:///Users/tilde/Projects/oss/import-meta-resolve/node_modules/@eslint/eslintrc/lib/index.js
6262
6363// A package with an export map:
64- console .log (await resolve (' tape /lib/test ' , import .meta.url))
65- // => file:///Users/tilde/Projects/oss/import-meta-resolve/node_modules/tape /lib/test .js
64+ console .log (resolve (' micromark /lib/parse ' , import .meta.url))
65+ // => file:///Users/tilde/Projects/oss/import-meta-resolve/node_modules/micromark /lib/parse .js
6666
6767// A node builtin:
68- console .log (await resolve (' fs' , import .meta.url))
68+ console .log (resolve (' fs' , import .meta.url))
6969// => node:fs
7070` ` `
7171
7272## API
7373
74- This package exports the identifiers [` resolve ` ][resolve ] and
75- [` moduleResolve ` ][moduleresolve ].
74+ This package exports the identifiers [` moduleResolve ` ][moduleresolve ] and
75+ [` resolve ` ][resolve ].
7676There is no default export.
7777
7878### ` resolve (specifier, parent)`
@@ -84,21 +84,23 @@ Match `import.meta.resolve` except that `parent` is required (you can pass
8484
8585* ` specifier` (` string` )
8686 — the module specifier to resolve relative to parent
87- (` /example.js` , ` ./example.js` , ` ../example.js` , ` some-package` , ` fs` , etc).
87+ (` /example.js` , ` ./example.js` , ` ../example.js` , ` some-package` , ` fs` , etc)
8888* ` parent` (` string` , example: ` import.meta.url` )
89- — the absolute parent module URL to resolve from.
90- You should pass ` import.meta.url` or something else.
89+ — the absolute parent module URL to resolve from; you must pass
90+ ` import.meta.url` or something else
9191
9292###### Returns
9393
94- Returns a promise that resolves to a full ` file:` , ` data:` , or ` node:` URL
95- (` string` ) to the found thing or rejects to an
96- [` ErrnoException` ][errnoexception].
94+ Full ` file:` , ` data:` , or ` node:` URL (` string` ) to the found thing
95+
96+ ###### Throws
97+
98+ Throws an [` ErrnoException` ][errnoexception].
9799
98100### ` moduleResolve(specifier, parent, conditions, preserveSymlinks)`
99101
100102The [“Resolver Algorithm Specification”][algo] as detailed in the Node docs
101- (which is sync and slightly lower-level than ` resolve` ).
103+ (which is slightly lower-level than ` resolve` ).
102104
103105###### Parameters
104106
@@ -177,6 +179,7 @@ lower-level than `resolve`).
177179
178180* ` parent` defaulting to ` import.meta.url` cannot be ponyfilled: you have to
179181 explicitly pass it
182+ * no support for loaders (that would mean implementing all of loaders)
180183* no support for CLI flags:
181184 ` --experimental-json-modules` , ` --experimental-wasm-modules` ,
182185 ` --experimental-policy` , ` --experimental-network-imports` , ` --no-addons` ,
@@ -196,7 +199,7 @@ It exports the additional type [`ErrnoException`][errnoexception].
196199## Compatibility
197200
198201This package is at least compatible with all maintained versions of Node.js.
199- As of now, that is Node.js 14.14+ and 16.0+ .
202+ As of now, that is Node.js 18 and later .
200203
201204## Contribute
202205
@@ -205,7 +208,7 @@ See [How to Contribute to Open Source][contribute].
205208
206209## License
207210
208- [MIT][license] © [Titus Wormer][author]
211+ [MIT][license] © [Titus Wormer][author] and Node.js contributors
209212
210213<!-- Definitions -->
211214
0 commit comments