-
Notifications
You must be signed in to change notification settings - Fork 5.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
LSP badly resolves relative imports between cached modules #19908
Comments
I now have "absolute" imports and cache-relative imports both working properly after moving the "absolute" entries in the import map ( "scopes": {
"./": {
"/": "./",
"./": "./"
} |
I personally strongly recommend revising the official documentation to include this as an example. |
… root imports Since the Deno LSP provides incorrect recommendations for absolute project root imports when using the official example, I suggest adding another example to resolve this issue. Reference issues: - denoland/deno#19908 - denoland/deno#17193
Hi @cosmoswafer I later switched the import map entry so I could prefix project-relative imports with "@/" instead of "/". Then I didn't need to use scopes any more. I don't know if the original issue I reported is still a problem. |
@adamgreg, I see. I’ve conducted another test on Deno 1.44.2, and it appears that the scoped import map is not functioning as expected. While prefixes like “@/”, “@root/”, and “@baba/” seem to work, following the example from the official documentation leads to annoying suggestions. I think most users will read the documentation first, so it would be beneficial to provide an idiomatic example there. |
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/.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.
It seems to be linked to an entry in the import map -
"/": "./"
, copied from the "Using project root for absolute imports" example in the manual . If I comment that out, the problem goes away. I think there must be some bug at play here.The text was updated successfully, but these errors were encountered: