fannheyward / coc-deno

Deno extension for coc.nvim

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Import map: unable to load a local module

FernandoBasso opened this issue · comments

I have import-map.json at the root directory of my project with this content:

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

This is the contents of .vim/coc-settings.json:

{
  "deno.enable": true,
  "deno.importMap": "./import-map.json",
  "tsserver.enable": false
}

And in some given test file, I have this as the first line:

import { assertEquals } from "/deps.ts";

That line causes the following error:

Unable to load a local module: "file:///deps.ts".
  Please check the file path. (deno no-local)

I cannot do gf to that file, for instance, and get no types or documentation whatsoever for assertEquals.

Running deno test --import-map ./import-map.json src/foo.test.ts works.

Is this an issue with my config/setup perhaps, or could it be some other problem?

It's import_map.json, not import-map.json.

It's import_map.json, not import-map.json.

This is what I have in .vim/coc-settings.json:

"deno.importMap": "./import-map.json"

Are you therefore implying that config is not honored?

Yet, renamed it to import_map.json, updated coc-settings.json accordingly, restarted vim and I still observe the same problems reported in the opening message.

I may have something else causing the problem, but I can't think of what it could be.

截屏2022-10-10 20 07 34

Have no idea about this, I just change to import_map.json, everything works as expected.

Test:

deps.ts
import_map.json
src/
src/foo.test.ts

cat deps.ts: export * from "https://deno.land/std@0.156.0/testing/asserts.ts";

Checked my configurations and found that I've global "deno.importMap": "./import_map.json", that's why change file name work for me.

Oh yeah! If from vim I do :CocConfig (which edits the global config) an add "deno.importMap": "./import_map.json" then it works.

image

Also, from the global config, import-map.json works too if that is how my import map is named. So, it looks like the local config is not being honored regarding the import map (it is working for enabling and disabling deno, for instance).

Still working on this, maybe there's something wrong on workspace configuration usage.

Fixed in v3.10.2

Confirm it is working! Great! Thanks!!