blob: fe3a40cd21071a1440ad0570b8c56c838aa1c1fc (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
## Import maps
> This is an unstable feature. Learn more about
> [unstable features](../runtime/stability.md).
Deno supports [import maps](https://github.com/WICG/import-maps).
You can use import maps with the `--importmap=<FILE>` CLI flag.
Current limitations:
- single import map
- no fallback URLs
- Deno does not support `std:` namespace
- supports only `file:`, `http:` and `https:` schemes
Example:
```js
// import_map.json
{
"imports": {
"http/": "https://deno.land/std/http/"
}
}
```
```ts
// hello_server.ts
import { serve } from "http/server.ts";
const body = new TextEncoder().encode("Hello World\n");
for await (const req of serve(":8000")) {
req.respond({ body });
}
```
```shell
$ deno run --allow-net --importmap=import_map.json --unstable hello_server.ts
```
|