Warning - this is an unstable feature..

About

This page is based on Import maps in the Deno manual.

This Import Maps standard.

  • Homepage
  • WICG - import-maps

    How to control the behavior of JavaScript imports

For use in general and outside of the Deno context, see the JS Import maps section of this cheatsheets guide.

How to use

This means you need a file like for the mapping:

  • import_map.json

And then all your imports can be from a short URLs like "react", without using the full URL and version all over.

Examples

Standard syntax

This is what an import looks like without an import map.

import { red } from "https://deno.land/std@0.82.0/fmt/colors"

Import map syntax

You can collect imports in a central file like this:

  • import_map.json
      {
         "imports": {
            "fmt/": "https://deno.land/std@0.82.0/fmt/"
         }
      }
    
  • colors.ts
      import { red } from "fmt/colors.ts";
    
      console.log(red("hello world"));
    

Then run as:

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