1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-12-25 08:39:09 -05:00
denoland-deno/docs/linking_to_external_code/import_maps.md

743 B

Import maps

Deno supports import maps.

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

Example:

import_map.json

{
   "imports": {
      "fmt/": "https://deno.land/std@$STD_VERSION/fmt/"
   }
}

color.ts

import { red } from "fmt/colors.ts";

console.log(red("hello world"));

Then:

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

To use your project root for absolute imports:

import_map.json

{
  "imports": {
    "/": "./",
    "./": "./"
  }
}

main.ts

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

This causes import specifiers starting with / to be resolved relative to the import map's URL or file path.