Adamgreg
Adamgreg13mo ago

LSP badly resolves relative imports between cached modules

I don't really understand this, but it looks to me like the LSP / VS Code has started resolving relative imports between cached modules badly. I'm running under a devcontainer, with the project root in /workspace/ and $DENO_DIR is /deno/.cache/deno . I can run my unit tests from a terminal ok, but if I try to run them in VS Code I get a "Module Not Found" error popup that shows an attempt to import a module from /workspace/deno/.cache/deno/.... If I open the (cached) module containing the failing import and hover the import statement I see a popup with the "Resolved Dependency" in the wrong place, outside the cache. Screenshots attached. I've tried deno cache -r, I've tried manually deleting the cache and re-caching, and I've tried rebuilding the whole devcontainer, but it didn't help. If I downgrade to Deno 1.35.1 I still see the bad "Resolved Dependency" message, but can't reproduce the unit test problem, because the unit tests won't run at all in VS Code (it reports "Running tests...", but seems to hang indefinitely, with no output) I'm fairly new to both Deno and VS Code, so please let me know if there is more debug information I can collect, or if there's anything else I should try to resolve the problem or investigate further. Thanks!
2 Replies
Adamgreg
Adamgreg13mo ago
For anyone with the same problem - this is linked to an entry in the import map - "/": "./", copied from here: https://deno.land/manual@v1.35.2/basics/import_maps#example---using-project-root-for-absolute-imports . If I comment that out, the problem goes away. Adding an explicit "../": "../" to the import map also resolves it, so that's what I've done
Adamgreg
Adamgreg13mo ago
I realised I probably should have just raised this as a bug, so I've done that now: https://github.com/denoland/deno/issues/19908
GitHub
LSP badly resolves relative imports between cached modules · Issue ...
I think the LSP / VS Code has started resolving relative imports between cached modules badly. I'm running under a devcontainer, with the project root in /workspace/ and $DENO_DIR is /deno/.cac...