feat: import.meta.resolve() (#15074)

This commit adds new "import.meta.resolve()" API which
allows to resolve specifiers relative to the module the API
is called in. This API supports resolving using import maps.
This commit is contained in:
Bartek Iwańczuk 2022-07-18 20:05:26 +02:00 committed by GitHub
parent 0d73eb3dd9
commit 999cbfb52b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 101 additions and 1 deletions

View file

@ -21,6 +21,16 @@ declare interface ImportMeta {
* ```
*/
main: boolean;
/** A function that returns resolved specifier as if it would be imported
* using `import(specifier)`.
*
* ```ts
* console.log(import.meta.resolve("./foo.js"));
* // file:///dev/foo.js
* ```
*/
resolve(specifier: string): string;
}
/** Deno supports user timing Level 3 (see: https://w3c.github.io/user-timing)