2020-05-06 18:21:13 -04:00
|
|
|
## Import maps
|
|
|
|
|
|
|
|
> This is an unstable feature. Learn more about
|
2020-05-09 09:15:26 -04:00
|
|
|
> [unstable features](../runtime/stability.md).
|
2020-05-06 18:21:13 -04:00
|
|
|
|
|
|
|
Deno supports [import maps](https://github.com/WICG/import-maps).
|
|
|
|
|
|
|
|
You can use import map 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
|
2020-05-09 07:09:57 -04:00
|
|
|
$ deno run --importmap=import_map.json --unstable hello_server.ts
|
2020-05-06 18:21:13 -04:00
|
|
|
```
|