1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-11-28 16:20:57 -05:00
denoland-deno/docs/linking_to_external_code/import_maps.md
Bartek Iwańczuk 0dc89c0a79
feat: stabilise import maps (#9526)
This commit stabilises import maps by removing requirement
on "--unstable" flag when "--import-map" flag is used.
2021-03-01 12:41:22 +01:00

739 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 starting directory for absolute imports:

import_map.json

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

main.ts

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

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

import_map.json

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