Import maps

Deno supports import maps.

You can use import maps with the --import-map=<FILE> CLI flag.

Example:

import_map.json

  1. { "imports": { "fmt/": "https://deno.land/std@0.90.0/fmt/" }}

color.ts

  1. import { red } from "fmt/colors.ts";
  2. console.log(red("hello world"));

Then:

  1. $ deno run --import-map=import_map.json color.ts

To use starting directory for absolute imports:

import_map.json

  1. { "imports": { "/": "./" }}

main.ts

  1. import { MyUtil } from "/util.ts";

You may map a different directory: (eg. src)

import_map.json

  1. { "imports": { "/": "./src/" }}