-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f9cbee7
commit 49fa456
Showing
2 changed files
with
32 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# Import maps | ||
|
||
This module is a JavaScript implementation of the | ||
[Import maps](https://html.spec.whatwg.org/multipage/webappapis.html#import-maps) spec. | ||
|
||
## Usage | ||
|
||
```js | ||
import { parseImportMap, resolveModuleSpecifier } from "https://deno.land/x/import_maps/mod.js"; | ||
|
||
const baseUrl = new URL(import.meta.url); | ||
const parsedImportMap = parseImportMap({ | ||
imports: { | ||
"std/": "https://deno.land/std/", | ||
} | ||
}, baseUrl); | ||
|
||
const resolved = resolveModuleSpecifier(parsedImportMap, baseUrl, "std/http/mod.ts"); | ||
console.log(resolved); // URL { href: "https://deno.land/std/http/mod.ts" } | ||
``` | ||
Alternatively, you can use `createEmptyImportMap()` to simulate a situation where no import map is provided. | ||
```js | ||
import { createEmptyImportMap, resolveModuleSpecifier } from "https://deno.land/x/import_maps/mod.js"; | ||
|
||
const importMap = createEmptyImportMap(); | ||
resolveModuleSpecifier(parsedImportMap, baseUrl, "https://example.com"); | ||
``` |