#Relative imports in import map.

3 messages · Page 1 of 1 (latest)

boreal folio
#

I can't get me relative imports in the import map to work.

A. setting the root doesn't work following these steps: https://deno.land/manual@v1.32.3/basics/import_maps#example---using-project-root-for-absolute-imports

B. Even using the import map for aliasing the gfm module doesn't work

import { CSS, render } from "$gfm"

and import map looks like

{
  "imports": {
    "$fresh/": "https://deno.land/x/fresh@1.1.5/",
    "preact": "https://esm.sh/preact@10.13.1",
    "preact/": "https://esm.sh/preact@10.13.1/",
    "preact-render-to-string": "https://esm.sh/*preact-render-to-string@5.2.6",
    "@preact/signals": "https://esm.sh/*@preact/signals@1.1.3",
    "@preact/signals-core": "https://esm.sh/*@preact/signals-core@1.2.3",
    "twind": "https://esm.sh/twind@0.16.19",
    "twind/": "https://esm.sh/twind@0.16.19/",
    "$gfm": "https://deno.land/x/gfm@0.1.26/mod.ts"
  }
}

throws this error

error: Uncaught (in promise) TypeError: Relative import path "$gfm" not prefixed with / or ./ or ../ and not in import map from "file:///Users/davitbalagyozyan/workplace/deno/personal-site/routes/[slug].tsx"
    at file:///Users/davitbalagyozyan/workplace/deno/personal-site/routes/[slug].tsx:2:29
  await import(entrypoint);
  ^
    at async dev (https://deno.land/x/fresh@1.1.5/src/dev/mod.ts:186:3)
    at async file:///Users/davitbalagyozyan/workplace/deno/personal-site/dev.ts:5:1
Watcher Process finished. Restarting on file change...

But the I switch the import to

import { CSS, render } from "https://deno.land/x/gfm@0.1.26/mod.ts"

it works fine. So something is the matter with my import_map.

I tried restarting the language server - no luck

toxic trail
#

Can you share the command you use to start deno?

#

Because for me everything works fine 😅